How to get container when overriding NSCreateCommand
How to get container when overriding NSCreateCommand
- Subject: How to get container when overriding NSCreateCommand
- From: Bill Cheeseman <email@hidden>
- Date: Wed, 13 Jul 2005 10:32:04 -0400
In my scriptable Core Data app, I have successfully overridden
NSCreateCommand so that I can create a new managed object and insert it in
the document's managed object context using AppleScript.
However, I don't know how to get a reference to the managed object's
container (a document), so that I can insert the new managed object into the
correct document as designated in the running script. In my override of
NSCreateCommand, all of the likely methods return nil: -directParameter,
-receiversSpecifier, -evaluatedReceivers.
Without knowing which document is being told to create the managed object, I
have to resort to assumptions or tricks that are not robust, and maybe I
can't even do it.
The script looks like this:
tell application "myApp"
tell document 1
make new company with properties {name:"myCompany"}
end tell
end tell
I know the information that I want is in there somewhere, because
+[NSScriptCommand currentCommand] returns a description that includes this
gem: "Container Specifier for created object: <NSIndexspecifier
orderedDocuments 2>". But I don't know how to get the underlying data so
that I can use it programmatically.
I suppose there must be a way to get it from -[NSScriptCommand appleEvent],
but I haven't figured out how. It's in the 'want' and 'seld' fields of the
event, I think.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
PreFab Software - http://www.prefab.com/scripting.html
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden