NSPortMessage defines a low-level, operating system-independent type for inter-application (and inter-thread) messages. Port messages are used primarily by the distributed objects system. You should implement inter-application communication using distributed objects whenever possible and use
NSPortMessage only when necessary.
- macOS 10.0+
NSPortMessage object has three major parts: the send and receive ports, which are
NSPort object that link the sender of the message to the receiver, and the components, which form the body of the message. The components are held as an
NSArray object containing
sendBeforeDate: message sends the components out through the send port; any replies to the message arrive on the receive port. See the
NSPort class specification for information on handling incoming messages.
NSPortMessage instance can be initialized with a pair of
NSPort objects and an array of components. A port message's body can contain only
NSPort objects or
NSData objects. In the distributed objects system the byte/character arrays are usually encoded
NSInvocation objects that are being forwarded from a proxy to the corresponding real object.
NSPortMessage object also maintains a message identifier, which can be used to indicate the class of a message, such as an Objective-C method invocation, a connection request, an error, and so on. Use the
msgid methods to access the identifier.