In my sdef I have some commands (subclasses of NSScriptCommand) from which I need to return lists and records.
To my surprise, the built-in support for AppleScript return types does not include lists. Records are also advised against, but I think I can handle building my own record-type elements (at least it seems straightforward enough).
However, most of the time, I just want to return a list (possibly of mixed types). I can’t find any examples of how this is done in the sdef’s on my own machine.
I note the docs mention that you can create your own value-types, but I’m not sure I fully understand how these work. Can I create my own return type for lists just by doing this (I’m assuming if it was that easy they’d be included to start with, but presumably I’m missing something – see Edit below)?
<value-type name="List" code="LisT"> <cocoa class="NSArray"/> </value-type>
And if not, is there some other way I might achieve this?
Trying it gave me this error message:
Error while returning the result of a script command: the result object…
could not be converted to an Apple event descriptor of type ‘List’. This instance of the class ‘Swift._SwiftDeferredNSArray’ doesn’t respond to -scriptingListDescriptor messages.