Anyone tried working with NSXPCConnection - Also BLOCKs

I’m looking at creating my 1st XPC Helper in Xcode.
And I’d like to be able to call it from AppleScript as well as my Obj-C Code.

Has anyone tried it?
It seems like I should be able to translate the code and execute it from AppleScript.
The only problem I see is the Block Reply:

From Xcode Template:


#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 DJ_K_Tel_XPC_HelperProtocol

// Replace the API of this protocol with an API appropriate to the service you are vending.
-(void)upperCaseString:(NSString*)aString withReply:(void (^)(NSString*))reply;
    
@end

/*
 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:@"com.technomorph.DJ-K-Tel-XPC-Helper"];
     _connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(DJ_K_Tel_XPC_HelperProtocol)];
     [_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];
*/

Anyone figured out any workarounds for Blocks?

I’m not sure if the NSXPCInterface protocol must return void as I could try to return a NSString


-(NSString*)upperCaseString:(NSString*)aString;

Or maybe I could use a pointer?


-(void)upperCaseString:(NSString*)aString withPointer:(NSString**)reply;