ヘルパー ツールがエラー ハンドラを介してインストールされているかどうかを検出しようとしていますが、エラー ブロックも成功ブロックも実行されません。ヘルパーが既にインストールされている場合、正常に動作します。エラーがある場合、エラーをキャッチしません。ドキュメントでは、常にこれら 2 つのブロックのいずれかが実行されます。
if helperToolConnection == nil {
let connection = NSXPCConnection(machServiceName: "**bundle identifier**", options: NSXPCConnectionOptions.Privileged)
connection.remoteObjectInterface = NSXPCInterface(withProtocol: HelperProtocol.self)
connection.invalidationHandler = {
self.helperToolConnection = nil
}
connection.resume()
helperToolConnection = connection
}
let helper = helperToolConnection!.remoteObjectProxyWithErrorHandler() { error in
NSLog("Failed to connect: \(error)")
withReply(nil)
} as! HelperProtocol
helper.connectWithEndpointReply() { endpoint -> Void in
withReply(endpoint)
}