Trouble implementing selection property

Steve Mills

I'm not sure what I'm doing wrong when adding a "selection" property to my document class so the user can get and set the selected assets. When I run:

tell application "Image Chest"
tell document 1
set blah to selection
set selection to blah
—>Can’t make asset 76 of document "_Untitled" into type specifier.
end tell
end tell

I've tried using both NSIndexSpecifier and NSUniqueIDSpecifier when returning the objectSpecifier for the Asset class, and they work if I do something simple like:

set blah to asset 1 of document 1
return name of blah

The selection property is structured in the sdef as:

<property name="selection" code="seld" description="The selected assets.">
<type type="asset" list="yes" />
<cocoa key="scriptableSelection" />

Do I need to override some method in some class, like indicesOfObjectsByEvaluatingObjectSpecifier:? I tried adding one of those to the Document class so I could inspect all the incoming specifiers, then returned nil so the default implementation would do the evaluation instead. It never gets called when the "set selection to blah" line is being run.

It's been a long time since I've done any serious AppleScript implementation, and that was in a huge Carbon app. So maybe I'm trying to do something that's impossible? Maybe I instead need to add a "select" verb?

Steve Mills
Drummer, Mac geek

Join to automatically receive all group messages.