Re: Cocoa AppleScript question
Re: Cocoa AppleScript question
- Subject: Re: Cocoa AppleScript question
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 17 Jan 2006 16:28:30 -0700
On Jan 17, 2006, at 3:33 PM, Brant Sears wrote:
1. The application has a concept of a set of "friends". To make
things simple, let's say each friend only has a first name.
Therefore, I don't really care whether the friend is a single
string or is a class that has a property that is a string called
"name".
You should care. If you want to make objects accessible via
AppleScript, they need to be your own custom object type and not a
generic model object (NSString, etc.). The reason is because (read on):
The result is that the CurrentFriend property works OK, but trying
to retrieve the list results in an error inside the application
that apparently has to do with NSScriptObjectSpecifier. I'm looking
at that class and I'm a bit baffled at the way it is being used in
the "Sketch" example.
How close am I to havin this do what I want?
If you want to make an object scriptable, then the object must
respond to the -objectSpecifier method, even if it's read-only. The -
objectSpecifier method must return an object that subclasses
NSScriptObjectSpecifier; there's a number of built-in object
specifiers that you can use. The object specifier needs to be able to
uniquely identify an object for AppleScript, so you can use a command
like "set theFriend to get friend with name \"Bob\"" to pull out the
correct object from the application.
The exceptions are subclasses of NSDocument, NSWindow, and
NSApplication; they already implement -objectSpecifier.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
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