I am still on my continuing mission to learn ApplescriptObjC, I have a query about how you call other
Applescripts and AOC Classes from the AppDelegate supplied by Xcode.
How do you make the call to other ApplescriptObjC classes, and any Methods contained in that Class ?
Also can you use Objective-C Classes in your ApplescriptObjC projects ?
And if you can, how do you make calls to the Objective-C class, and any Methods contained within ?
Some short code snippets would be appreciated on the above questions.
Do you mean classes or existing objects? To create an object (let’s say it names classA)
set instanceOfClassA to current application's class "classA"'s alloc()'s init()
to call a class method it’s like this.
current application’s class “classA”'s classMethod()
Yes, a cocoa class like NSString is also an Objective-C class
I didn’t put example code because I think, in the first posts of AppleScriptObjC forum, how you need to write AppleScriptObjC. Also if these things are hard for you I would recommend shane’s book. For only a few bucks you’ll spare yourself a couple of hours searching on the forums.
What I ment to say was that if I added a new file to a project, of a type ApplescriptObjC Class
or Objective-C class, then how you would go about calling them or there methods.
Yes at some point I will check out Shanes book, just trying to decide wether to stick with
ApplescriptObjC, or learn Objective-C.
It would be nice to use both in the same projects.
FWIW, Learning regular ObjC will make doing ASOC a lot more understandable. When you know what the ObjC classes do, calling them and linking to them makes a lot more sense. So I think you can learn both together. I am using both in the same projects and calling data back and forth between them. Initially it’s a little tricky to make sure you have a class instantiated and get those values, versus calling it’s class functions.
So I have an app that uses 95% Objective C classes, and 1 Applescript class. This Applescript class needs to get some data from the ObjC object.
Here is part of my Applescript class:
property parent : class "NSObject"
property appDelegate : missing value --link to instance in IB
on buildTemplate_(sender) --a button in the UI calls this function
set adDealOrOPP to (appDelegate's adDealOrOPP) as integer --< this gets some data from the AppDelegate class
set salesRep to (salesRepTF's stringValue) as string --< this gets a value from the AppDelegate class as well
So to clear things up a bit- you can have a CLASS object and you can call it’s class methods (start with +) in ObjC, and there is one syntax to do that. Or like I show here, you have to make a blue cube object in Interface Builder (or you can do it programmatically I think) so your ASOC object can talk to the OBJC object that has your current data.
That all helps a lot.
I think your right about learning Objective-C being a good idea, after all to learn
ApplescriptObjC you end up reading a lot of documentation with Objective-C code
examples, it just seems to me as a beginner and hobbyist like a lot of study
and work, but i think it is the right way to go.