To sum up:
I have two apps (A and B) both written by me, both not scriptable, both not 
using Sandbox (yet).

A wants to send something to B (e.g. a serialisable Dictionary) and get some 
answer back (e.g. also a Dictionary).
B should show some relevant info related to A's request.

Step 1: Use XPC.

B does:
listener = [[NSXPCListener alloc] initWithMachServiceName: bundleId ];

and A does try to send, but fails.

The documentation says about initWithMachServiceName: "Initializes a listener 
in a LaunchAgent or LaunchDaemon which has a name advertised in a launchd.plist 
file."
Which seems to imply that this cannot work in app B, which is just an ordinary 
app.

Is there some other way to make this work? Or should I just forget about XPC?

NSXPCListener can get an NSXPCListenerEndpoint, which is "an endpoint object 
that may be sent over an existing connection."
And NSXPCConnection has initWithListenerEndpoint: which "Initializes an 
NSXPCConnection object to connect to an NSXPCListener object in another 
process, identified by an NSXPCListenerEndpoint object."
Might this be a way to make it work (no idea how to get the 
NSXPCListenerEndpoint from B to A yet).
The documentation for NSXPCListenerEndpoint is somewhat terse. But it does 
NSSecureCoding.


Step 2: Use Apple Events.

The documentation for NSAppleEventDescriptor says: "Cocoa doesn’t currently 
provide a mechanism for applications to directly send raw Apple events" and 
mentions Apple Events Programming Guide and Apple Event Manager Reference, 
without providing a link to these documents.
And Xcode seems not to know of these documents either.

Scripting Bridge SBObject has a sendEvent:id:parameters:. Not sure I want to 
use this.

Technical Q&A QA1134 seems to suggest that one has to:
1. create an evenDescriptor (using AECreateDesc or maybe NSAppleEventDescriptor)
2. create an apple event from this evenDescriptor (using AECreateAppleEvent - 
no known Cocoa equivalent)
3. send this apple event via AESend.

When I ask Xcode about these functions, the only thing I get offered are some 
man-pages about "User Contributed Perl Documentation". Not too helpful.

Is there some documentation about these functions? Are they already deprecated? 
If so, what is the current way with Apple Events?

Xcode 5.1.2 has some info about AESend; but it warns: "This document may not 
represent best practices for current development."

Which begs the question: How do current developers send Apple Events?


Gerriet.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to