【发布时间】:2016-02-09 23:03:20
【问题描述】:
我正在尝试检测是否通过错误处理程序安装了帮助工具,但错误块不会被执行,成功块也不会执行。当助手已经安装时,它工作正常。它只是不会在有错误时捕获错误。在文档中,这两个块中的一个总是被执行
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)
}
【问题讨论】:
-
那么你看到了什么效果?它会崩溃吗,如果是,在哪里以及出现什么错误?