Creating objects via AppleScript and setting readonly properties


Steve Mills
 

This seems like bug, or I need to override something. I have a class:

@interface Blah : NSObject
@property (readonly) NSUInteger id;
@end

The id property is exposed to AppleScript in the Blah class:

<property name=“id” code=“ID “ type=“integer” access=“r”>
<cocoa key=“id” />
</property>

If I make a new Blah like so:

make new blah at end of doc with properties {name:”Bob”, id:17}

The Blah is created and the id is happily set to 17. Shouldn’t something prevent that, either st the AppleScript level (access=“r”) or the Cocoa level ((readonly))?

Or do I need to implement -setId and have it return an error to AppleScript? Or is there something else I’m missing?

Oh, a side question. Is there any way to #include headers in an .sdef file so constants or #defines can be used and stringified? Seems problematic to have to type 4-char codes all through an sdef when the constants are already defined in private and Apple headers. I haven’t tried, but thought I’d ask, since I don’t see an Xcode setting for preprocessing sdefs or anything like that.

Steve via iPhone

Join cocoa@apple-dev.groups.io to automatically receive all group messages.