Class

NSMachPort

NSMachPort is a subclass of Port that can be used as an endpoint for distributed object connections (or raw messaging). NSMachPort is an object wrapper for a Mach port, the fundamental communication port in macOS. NSMachPort allows for local (on the same machine) communication only. A companion class, SocketPort, allows for both local and remote distributed object communication, but may be more expensive than NSMachPort for the local case.

Overview

To use NSMachPort effectively, you should be familiar with Mach ports, port access rights, and Mach messages. See the Mach OS documentation for more information.

Nested Types

Symbols

Creating and Initializing

class func port(withMachPort: UInt32)

Creates and returns a port object configured with the given Mach port.

class func port(withMachPort: UInt32, options: NSMachPort.Options = [])

Creates and returns a port object configured with the specified options and the given Mach port.

init(machPort: UInt32)

Initializes a newly allocated NSMachPort object with a given Mach port.

init(machPort: UInt32, options: NSMachPort.Options = [])

Initializes a newly allocated NSMachPort object with a given Mach port and the specified options.

Getting the Mach Port

var machPort: UInt32

The Mach port used by the receiver, represented as an integer.

Scheduling the Port on a Run Loop

func remove(from: RunLoop, forMode: RunLoopMode)

Removes the receiver from the run loop mode mode of runLoop.

func schedule(in: RunLoop, forMode: RunLoopMode)

Schedules the receiver into the run loop mode mode of runLoop.

Getting and Setting the Delegate

func delegate()

Returns the receiver’s delegate.

func setDelegate(NSMachPortDelegate?)

Sets the receiver’s delegate to a given object.

Constants

Mach Port Rights

Used to remove access rights to a mach port when the NSMachPort object is invalidated or destroyed.

Relationships

Inherits From

Conforms To