<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/PortDelegate/handle(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSPortDelegate(im)handlePortMessage:"
  },
  "title" : "handle(_:)"
}
-->

# handle(_:)

Processes a given incoming message on the port.

```
optional func handle(_ message: NSPortMessage)
```

## Parameters

`message`

An incoming port message.

## Discussion

See [`Port`](/documentation/Foundation/Port) for more information.

The delegate should implement either [`handle(_:)`](/documentation/Foundation/PortDelegate/handle(_:)) or the [`NSMachPortDelegate`](/documentation/Foundation/NSMachPortDelegate) protocol method [`handleMachMessage(_:)`](/documentation/Foundation/NSMachPortDelegate/handleMachMessage(_:)). You must not implement both delegate methods.

## See Also

  [Distributed Objects Programming Topics](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html#//apple_ref/doc/uid/10000102i)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)