Post

Replies

Boosts

Views

Activity

Comment on *Really* unusual XPC/Swift question
Ok. I've got this code, and proxy still ends up as nil. I'm still playing with it so hopefully I'll figure out on my own what I'm doing wrong. import Foundation class ConnectionHandler: NSObject, NSXPCListenerDelegate {     override init() { super.init() print("ConnectionHandler.init()")     }     func listener(_ listener: NSXPCListener, shouldAcceptNewConnection newConnection: NSXPCConnection) -> Bool { print("ConnectionHandler.listener()") newConnection.resume() return true     } } let handler = ConnectionHandler() let listener = NSXPCListener.anonymous() let endpoint = listener.endpoint listener.delegate = handler listener.resume() @objc protocol Hello {     func hello() } class HelloClass: NSObject, Hello {     override init() { super.init()     }     func hello() { print("In HelloClass.hello()")     } } let hello = HelloClass() let connection = NSXPCConnection(listenerEndpoint: endpoint) connection.exportedInterface = NSXPCInterface(with: Hello.self) print("Connection = \(connection)") connection.resume() let proxy = connection.remoteObjectProxyWithErrorHandler({ error in   print("Got error \(error)") }) as? Hello print("Proxy = \(proxy)") dispatchMain()
Jul ’21