Contents

accept(connection:)

Returns a Boolean value that indicates whether you accept an incoming connection request from the host app.

Declaration

nonisolated func accept(connection: NSXPCConnection) -> Bool

Parameters

  • connection:

    A connection object you can use to communicate with the host app.

Mentioned in

Return Value

true if you accept the connection to the host app, or false if you don’t.

Discussion

Implement this method in your custom type and use it to establish communication between your app extension and the host app that made the request. To accept a connection request, set the connection’s exportedObject property to an object in your app extension that implements a protocol or type from the host’s SDK. Similarly, put the type information in the doc://com.apple.documentation/documentation/foundation/nsxpcconnection/exportedinterface property. You can also retrieve other relevant properties of the connection object, such as the remote connection details, and use them to set up your app extension. When you’re ready to start communicating with the host, call the connection’s resume() method and then return true from this method.