---
title: "init(send:receive:components:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/portmessage/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.

## Declaration

```swift
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

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

## Discussion

Discussion An NSPortMessage object initialized with this method has a message identifier of 0. This is the designated initializer for NSPortMessage.

## See Also

### Related Documentation

- [msgid](foundation/portmessage/msgid.md)
- [Distributed Objects Programming Topics](apple-archive/documentation/Cocoa/Conceptual/DistrObjects.md)
