Thanks Shane. I didn’t know that about loaded scripts. If I may follow up, what happens when the loaded script has the property parent: class “NSObject” line? A script can’t have two parents can it? I ask because it seems like it might be useful if the loaded scripts can have access to the loading scripts handlers and properties via inheritance, but I can’t make it work. BTW, I picked up your book and I’ve just started getting into it, so if it’s covered in there somewhere, feel free to just refer to a page number :).
No, it can’t, and I’m not sure what the result will be – I’ve never tried specifying a parent in a loaded script. Just add the line:
log | superclass|()
to the loaded script, and you can probably tell me
Hmmm, curiosity got the better of me. Looks like NSObject is the parent, and it gives an error if it’s not. That sort of fits in with the following…
You can get at the properties, but you can’t call the handlers.
IMO, you’ll probably be better off to put the stuff you’re loading in separate classes, rather than rely on load script. Then you can get at both properties and handlers. It also lets you implement setters and getters for your properties, which can be useful at times. The downside is that you’ll need to follow the Cocoa naming conventions, and coerce results and arguments (because they’re all travelling via Cocoa-land).
The ‘Handlers as Methods’ chapter of the Reference Section covers the issues with calling methods between script objects. And thanks for buying the book!