<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/PortMessage/init(send:receive:components:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPortMessage(im)initWithSendPort:receivePort:components:"
  },
  "title" : "init(send:receive:components:)"
}
-->

# init(send:receive:components:)

Initializes a newly allocated `NSPortMessage` object to send given data on a given port and to receiver replies on another given port.

```
init(send sendPort: Port?, receive replyPort: Port?, components: [Any]?)
```

## Parameters

`sendPort`

The port on which the message is sent.

`replyPort`

The port on which replies to the message arrive.

`components`

The data to send in the message. `components` should contain only `NSData` and `NSPort` objects, and the contents of the `NSData` objects should be in network byte order.

## Return Value

An `NSPortMessage` object initialized to send `components` on `sendPort` and to receiver replies on `receivePort`.

## Discussion

An `NSPortMessage` object initialized with this method has a message identifier of 0.

This is the designated initializer for `NSPortMessage`.

## See Also

[`msgid`](/documentation/Foundation/PortMessage/msgid)

Returns the identifier for the receiver.

  [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)