Adding scripting support for custom records


Steve Mills
 

What's the best way to return data from a scriptable app when the property is a record-type that's declared in the sdef? It corresponds to an Objective-C class. I ended up adding a separate property to the owner class that returns the data in an NSDictionary and using that property in the sdef instead of the real property, which is the normal Objective-C class. But it feels like there should be a more simple way that I haven't been able to glean from the spotty documentation I've found so far.

I feel so dumb about this, having previously been about half responsible for implementing the AppleScript support and recordability for one of the best page layouts apps ever written back in the Carbon days.

--
Steve Mills
Drummer, Mac geek


Bill Pitcher
 

I can’t add much other than I recall yours was the solution I used too.

Off-Topic
WWDC is very close and I’d be surprised if there aren’t significant changes to the whole Scripting shambles (I hope). YMMV

cheers
Bill

On 7 May 2019, at 1:42 pm, Steve Mills via Groups.Io <sjmills@...> wrote:

What's the best way to return data from a scriptable app when the property is a record-type that's declared in the sdef? It corresponds to an Objective-C class. I ended up adding a separate property to the owner class that returns the data in an NSDictionary and using that property in the sdef instead of the real property, which is the normal Objective-C class. But it feels like there should be a more simple way that I haven't been able to glean from the spotty documentation I've found so far.

I feel so dumb about this, having previously been about half responsible for implementing the AppleScript support and recordability for one of the best page layouts apps ever written back in the Carbon days.

--
Steve Mills
Drummer, Mac geek




Shane Stanley
 

On 7 May 2019, at 1:42 pm, Steve Mills via Groups.Io <sjmills@...> wrote:

What's the best way to return data from a scriptable app when the property is a record-type that's declared in the sdef? It corresponds to an Objective-C class. I ended up adding a separate property to the owner class that returns the data in an NSDictionary and using that property in the sdef instead of the real property, which is the normal Objective-C class.
if I follow you correctly, that sounds about right. Cocoa scripting doesn't like simple records -- it wants custom record types.

--
Shane Stanley <sstanley@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


Steve Mills
 

On May 6, 2019, at 22:54:12, Shane Stanley <sstanley@...> wrote:

if I follow you correctly, that sounds about right. Cocoa scripting doesn't like simple records -- it wants custom record types.
OK, thanks for the confirmation. I was hoping there was something analogous to -objectSpecifier that I wasn't finding, such as -valueDdescriptor that would be called on the key-value object found at the object's property and return an NSAppleEventDescriptor.

--
Steve Mills
Drummer, Mac geek


Alex Zavatone
 

How do you plan to consume it? As an array, dictionary? You can even save it out as a pList and read it off media if you wish. You can even serialize it to JSON or XML. There even is serializing through NSCodable, but in this case, you would need to have the format to deserialize in your target app.

Actually, I wonder if you could use app groups and simply make the data common between apps running in that group or are you planning on accessing the data through scripting?

How do you wish to read the data in?

On May 6, 2019, at 10:42 PM, Steve Mills via Groups.Io <sjmills@...> wrote:

What's the best way to return data from a scriptable app when the property is a record-type that's declared in the sdef? It corresponds to an Objective-C class. I ended up adding a separate property to the owner class that returns the data in an NSDictionary and using that property in the sdef instead of the real property, which is the normal Objective-C class. But it feels like there should be a more simple way that I haven't been able to glean from the spotty documentation I've found so far.

I feel so dumb about this, having previously been about half responsible for implementing the AppleScript support and recordability for one of the best page layouts apps ever written back in the Carbon days.

--
Steve Mills
Drummer, Mac geek




Steve Mills
 

On May 7, 2019, at 14:46:25, Alex Zavatone via Groups.Io <zav@...> wrote:

How do you plan to consume it? As an array, dictionary? You can even save it out as a pList and read it off media if you wish. You can even serialize it to JSON or XML. There even is serializing through NSCodable, but in this case, you would need to have the format to deserialize in your target app.

Actually, I wonder if you could use app groups and simply make the data common between apps running in that group or are you planning on accessing the data through scripting?
What? I think you misunderstood. This is purely AppleScript communication. Bill and Shane already confirmed I'm doing the right thing.

--
Steve Mills
Drummer, Mac geek