I'm trying to communicate apps with each other.
I'm handling Apple Events in my first application with
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(handleGetURLEvent), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
func handleGetURLEvent(_ event: NSAppleEventDescriptor, withReplyEvent replyEvent: NSAppleEventDescriptor)
In the second app I'm creating NSAppleEventDescriptor object
let test = NSAppleEventDescriptor(string: "test")
let descriptor = NSAppleEventDescriptor(eventClass: AEEventClass(kInternetEventClass), eventID: AEEventID(kAEGetURL), targetDescriptor: nil, returnID: AEReturnID(kAutoGenerateReturnID), transactionID: AETransactionID(kAnyTransactionID))
descriptor.setParam(test, forKeyword: keyDirectObject)
Now with NSWorkspace
I'm launching my first app
NSWorkspace.shared().launchApplication(at: myAppUrl, options: .default, configuration: [NSWorkspaceLaunchConfigurationAppleEvent:descriptor])
Everything is ok, function handleGetURLEvent
is called, but... replyEvent.desciptorType
is kAENullEvent
also I don't have clue how would I get replyEvent
in my second app.
I suppose there is something wrong with this solution.
So my question is how can I simply send data to my other app and get some data back?