Comunique-se com outro aplicativo usando XPC

Eu tenho um aplicativo em janela e, para adicionar algumas funcionalidades, preciso de outro aplicativo que inicie no login e sincronize os dados com o servidor, se disponível.

Eu tentei com o NSDistributionNotification, mas é praticamente inútil em um aplicativo em área restrita. Procurei o XPC e esperava que funcionasse, mas não sei como fazê-lo funcionar com o ajudante. Até agora eu fiz isso usando XPC.

App principal

    NSXPCInterface *remoteInterface = [NSXPCInterface interfaceWithProtocol:@protocol(AddProtocol)];
    NSXPCConnection *xpcConnection = [[NSXPCConnection alloc] initWithServiceName:@"com.example.SampleService"];

    xpcConnection.remoteObjectInterface = remoteInterface;

    xpcConnection.interruptionHandler = ^{
        NSLog(@"Connection Terminated");
    };

    xpcConnection.invalidationHandler = ^{
        NSLog(@"Connection Invalidated");
    };

    [xpcConnection resume];

    NSInteger num1 = [_number1Input.stringValue integerValue];
    NSInteger num2 = [_number2Input.stringValue integerValue];

    [xpcConnection.remoteObjectProxy add:num1 to:num2 reply:^(NSInteger result) {
        NSLog(@"Result of %d + %d = %d", (int) num1, (int) num2, (int) result);
    }];

Serviço XPC

In main () ...
SampleListener *delegate = [[SampleListener alloc] init];
NSXPCListener *listener = [NSXPCListener serviceListener];
listener.delegate = delegate;
[listener resume];

// In delegate
-(BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
    NSXPCInterface *interface = [NSXPCInterface interfaceWithProtocol:@protocol(AddProtocol)];
    newConnection.exportedInterface = interface;
    newConnection.exportedObject = [[SampleObject alloc] init];
    [newConnection resume];
    return YES;
}

// In Exported Object class

-(void)add:(NSInteger)num1 to:(NSInteger)num2 reply:(void (^)(NSInteger))respondBack {
    resultOfAddition = num1 + num2;
    respondBack(resultOfAddition);
}

Isso funciona bem, agora eu preciso passar esse resultado para o aplicativo Helper. Como posso fazer isso ? Se XPC não é a resposta aqui para se comunicar, qual devo usar? Alguma dica, por favor?

questionAnswers(2)

yourAnswerToTheQuestion