pEp macOS Desktop adapter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

// pEpMacOSAdapterProtocol.h
// pEpMacOSAdapter
// Created by Volker Birk on 20.04.20.
// Copyleft © 2020 p≡p foundation.
// This file is under GNU General Public License 3.0
#import <Foundation/Foundation.h>
// The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
@protocol pEpMacOSAdapterProtocol
// Replace the API of this protocol with an API appropriate to the service you are vending.
- (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply;
To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this:
_connectionToService = [[NSXPCConnection alloc] initWithServiceName:@""];
_connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(pEpMacOSAdapterProtocol)];
[_connectionToService resume];
Once you have a connection to the service, you can use it like this:
[[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) {
// We have received a response. Update our text field, but do it on the main thread.
NSLog(@"Result string was: %@", aString);
And, when you are finished with the service, clean up the connection like this:
[_connectionToService invalidate];