init(endpoint:targetQueue:options:cancellationHandler:)
Creates a new session object representing a connection to the xpc endpoint.
Declaration
@preconcurrency convenience init(endpoint: XPCEndpoint, targetQueue: DispatchQueue? = nil, options: XPCSession.InitializationOptions = .none, cancellationHandler: (@Sendable (XPCRichError) -> Void)? = nil) throwsParameters
- endpoint:
The endpoint to create a session with.
- targetQueue:
The GCD queue onto which session events will be submitted. This may be a concurrent queue. This parameter is optional, if the target queue is not specified the target queue will be libdispatch’s default target queue, defined as
DISPATCH_TARGET_QUEUE_DEFAULT. - options:
Additional attributes which which to create the session.
- cancellationHandler:
The cancellation handler block that will be executed when this session is cancelled. This parameter is optional. See
setCancellationHandler()
Return Value
Returns a new session object. The returned session is activated by default and can be used to send messages.
Discussion
This will throw a XPCRichError if the specified endpoint is invalid or unavailable.