Function

xpc_connection_send_message_with_reply_sync(_:_:)

Declaration

func xpc_connection_send_message_with_reply_sync(_ connection: xpc_connection_t, _ message: xpc_object_t) -> xpc_object_t

Parameters

connection

The connection over which the message shall be sent.

message

The message to send. This must be a dictionary object.

Return Value

The message that the remote service sent in reply to the original message. If the remote service exits prematurely before the reply was received, the XPC_ERROR_CONNECTION_INTERRUPTED error will be returned. If the connection went invalid before the message could be sent, the XPC_ERROR_CONNECTION_INVALID error will be returned.

You are responsible for releasing the returned object.

Discussion

This API is primarily for transitional purposes. Its implementation is conceptually equivalent to calling xpc_connection_send_message_with_reply() and then immediately blocking the calling thread on a semaphore and signaling the semaphore from the reply block.

Be judicious about your use of this API. It can block indefinitely, so if you are using it to implement an API that can be called from the main thread, you may wish to consider allowing the API to take a queue and callback block so that results may be delivered asynchrously if possible.