我正在尝试检测是否通过错误处理程序安装了辅助工具,但错误块不会被执行,成功块也不会执行。当助手已经安装时,它工作正常。它只是不会在有错误时捕获错误。在文档中,这两个块中的一个总是被执行
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)
}