init(xpcService:targetQueue:options:incomingMessageHandler:cancellationHandler:)
Establishes a connection to an XPC service with the name and dictionary message handler you specify.
Declaration
@preconcurrency convenience init(xpcService: String, targetQueue: DispatchQueue? = nil, options: XPCSession.InitializationOptions = .none, incomingMessageHandler: (@Sendable (XPCDictionary) -> XPCDictionary?)? = nil, cancellationHandler: (@Sendable (XPCRichError) -> Void)? = nil) throwsParameters
- xpcService:
The name of the XPC service to connect to.
- targetQueue:
The dispatch queue to use for session events. You can specify a concurrent dispatch queue. If you specify Nil 227m0, the session uses
DISPATCH_TARGET_QUEUE_DEFAULT. - options:
Attributes the session uses when establishing the connection.
- incomingMessageHandler:
A closure the system calls when a client initiates a connection to the server.
- cancellationHandler:
A closure the system calls when it cancels a session.
Discussion
If the service isn’t found or is unavailable, the connection fails and this method throws an error.
By default, this method activates the session it creates and the session is ready to accept messages. To create an inactive session, specify inactive in the options parameter.
See Also
Creating a session
init(xpcService:targetQueue:options:incomingMessageHandler:cancellationHandler:)init(xpcService:targetQueue:options:incomingMessageHandler:cancellationHandler:)init(xpcService:targetQueue:options:cancellationHandler:)init(machService:targetQueue:options:incomingMessageHandler:cancellationHandler:)init(machService:targetQueue:options:incomingMessageHandler:cancellationHandler:)init(machService:targetQueue:options:incomingMessageHandler:cancellationHandler:)init(machService:targetQueue:options:cancellationHandler:)XPCSession.InitializationOptionssetTargetQueue(_:)