Class

NSXPCConnection

The NSXPCConnection class provides a bi-directional communication channel between two processes.

Overview

This class is the primary means of creating and configuring the communication mechanism between two processes. Each process has one instance of this class to represent the endpoint in the communication channel.

Nested Types

NSXPCConnectionOptions

Options that you can pass to a connection.

Symbols

Creating Connections

init(listenerEndpoint: NSXPCListenerEndpoint)

Initializes an NSXPCConnection object to connect to an NSXPCListener object in another process, identified by an NSXPCListenerEndpoint object.

init(machServiceName: String, options: NSXPCConnection.Options = [])

Initializes an NSXPCConnection object to connect to a LaunchAgent or LaunchDaemon with a name advertised in a launchd.plist.

init(serviceName: String)

Initializes an NSXPCConnection object to connect to an NSXPCListener object in an XPC service, identified by a service name.

Miscellaneous

func invalidate()

Invalidates the connection.

var remoteObjectProxy: Any

Returns a proxy for the remote object (that is, the exportedObject from the other side of this connection).

func remoteObjectProxyWithErrorHandler( (Error) -> Void)

Returns a proxy for the remote object (that is, the object exported from the other side of this connection) with the specified error handler.

func resume()

Starts or resumes handling of messages on a connection.

func suspend()

Suspends the connection.

var serviceName: String?

The name of the XPC service that this connection was configured to connect to.

var remoteObjectInterface: NSXPCInterface?

Defines the NSXPCInterface object that describes the protocol for the object represented by the remoteObjectProxy.

var processIdentifier: pid_t

The process ID (PID) of the connecting process.

var invalidationHandler: (() -> Void)?

An invalidation handler that is called if the connection can not be formed or the connection has terminated and may not be re-established.

var interruptionHandler: (() -> Void)?

An interruption handler that is called if the remote process exits or crashes.

var exportedObject: Any?

An exported object for the connection.

var exportedInterface: NSXPCInterface?

The NSXPCInterface object that describes the protocol for the exported object on this connection.

var endpoint: NSXPCListenerEndpoint

If the connection was created with an NSXPCListenerEndpoint object, returns the endpoint object used.

var effectiveUserIdentifier: uid_t

The effective user ID (EUID) of the connecting process.

var effectiveGroupIdentifier: gid_t

The effective group ID (EGID) of the connecting process.

var auditSessionIdentifier: au_asid_t

The BSM audit session identifier for the connecting process.

Constants

Options

Options that you can pass to a connection.

Relationships

Inherits From