AppleScript: Returning object references in Cocoa
AppleScript: Returning object references in Cocoa
- Subject: AppleScript: Returning object references in Cocoa
- From: Fritz Anderson <email@hidden>
- Date: Tue, 24 May 2005 11:46:17 -0500
I'm working with the 10.4-format sdef, and testing on 10.4. I'm
having a number of problems, all of which I believe trace back to the
fact that I don't seem to be able to usefully access object
references as return values from gets of elements.
Imagine these classes:
application (n)
elements
contains settings
...
setting (n)
properties
name (string)
id (string)
...
The (abbreviated) sdef looks like this:
<class name="application" code="capp"...>
<cocoa class="NSApplication">
<element type="setting" ...>
<cocoa key="entries"/>
<accessor style="id"/> <accessor style="test"/>
<accessor style="name"/> <accessor style="index"/>
</element>
...
</class>
<class name="setting" code="Setg"...>
<cocoa class="Setting">
<property name="name" code="pnam" type="string" ...>
<cocoa key="name"/>
<property/>
<property name="id" code="ID " type="string" access="r" ...>
<cocoa key="uuid"/>
<property/>
...
</class>
So anyway, my application delegate responds to
application:delegateHandlesKey:@"setting" with YES, and implements a
complete set of conventional indexed KVC methods.
If I execute the script
tell application "MyApp" to get setting 1
the objectInEntriesAtIndex: method is called, and returns an instance
of Setting. I have debugging output turned on, and see that the
object makes it to the AppleScript handler, but by the time it gets
back to the originating AppleScript, it is converted to a null. I had
hoped for some sort of reference.
I tried jiggering the indexed accessor so that it returned an
NSUniqueIDSpecifier, but (a) the specifier shows up in the calling
AppleScript with the right ID but an empty generic class; and (b) the
reference is useless for further use.
How can I arrange it so both of the following lines work?
tell application "MyApp" to get setting 1
tell application "MyApp" to get the color of setting 1
Should I not be working with KVC-compliance accessors at all, and
stick with NSScriptKVC-compliance accessors?
-- F
_______________________________________________
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