I've got a target in my Xcode project that generate XPCService. Now I wish to implement more functions of different context, so I'd like to add them into different protocol.
I wish that the current xpc service support connections from both protocols.
the default code for single protocol support looks like this :
// Create the delegate for the service.
ServiceDelegate *delegate = [ServiceDelegate new];
// Set up the one NSXPCListener for this service. It will handle all incoming connections.
NSXPCListener *listener = [NSXPCListener serviceListener];
listener.delegate = delegate;
// Resuming the serviceListener starts this service. This method does not return.
[listener resume];
whereas the ServiceDelegate
has the following method :
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
and I set the protocol for that connection decisively without option to choose myFirstProtocol
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(myFirstProtocol)];
now I have mySecondProtocol
as well and I want to choose protocol according to connection attribute that I send on the client side .. I'm looking for some sort of identifier that help me select the right interface.
thanks !