So it seems that as-of a recent version of XCode or perhaps OSX 10.6 AppleScript Studio (ASS) is no longer available. Instead there is a new thing called AppleScriptObjC that lets you write classes in AppleScript and use all of the Cocoa framework from AppleScript.
I've written a small app using this (see this thread).
I though that I'd attach the project here in case it helps anyone else learn how to use this new feature in XCode.
Things to notice. You can declare IBOutlets like this:
Basically any property with a starting value of "missing value" will be treated as an IBOutlet by Interface Builder. Note that as AppleScript is not typed in the same was as Objective-C we don't need to declare types.
IBActions look like this:
Note the _ in the name? This is a critical part of the bridge. This tells the compiler/bridge that this can be called from Obj-C and that there is a parameter. If we want methods with multiple parameters we can have them like:
We can also call into Objective-C/use Objective-C objects from our AppleScript. If we have a property called myButton that we've connected in IB to a NSButton then this would make that button disabled:
Note the _ again. This is because we are calling setEnabled: on the UIControl.
We can also call Objective-C methods with a different syntax. It looks like this:
The important part here is the "'s". The variable/property is called myObject. The 's tells the system we are calling a method.
Note that as the object that your code is in is a NSObject you can call methods on the object itself that are part of the NSObject protocol. So you can do this to run a method with a delay:
This will call the AppleScript "method" loop after 1.0 seconds and not repeat. Note that this loop was declared as:
Note the lack of _
And that's about all I know! Is anyone else using this?
I've written a small app using this (see this thread).
I though that I'd attach the project here in case it helps anyone else learn how to use this new feature in XCode.
Things to notice. You can declare IBOutlets like this:
Code:
property myOutlet : missing value
Basically any property with a starting value of "missing value" will be treated as an IBOutlet by Interface Builder. Note that as AppleScript is not typed in the same was as Objective-C we don't need to declare types.
IBActions look like this:
Code:
on start_(sender)
<code goes here>
end start_
Note the _ in the name? This is a critical part of the bridge. This tells the compiler/bridge that this can be called from Obj-C and that there is a parameter. If we want methods with multiple parameters we can have them like:
Code:
on myMethod_withTwoParams_(param1,param2)
We can also call into Objective-C/use Objective-C objects from our AppleScript. If we have a property called myButton that we've connected in IB to a NSButton then this would make that button disabled:
Code:
property myButton : missing value
...
tell myButton to setEnabled_(false)
Note the _ again. This is because we are calling setEnabled: on the UIControl.
We can also call Objective-C methods with a different syntax. It looks like this:
Code:
myObject's method_(param)
The important part here is the "'s". The variable/property is called myObject. The 's tells the system we are calling a method.
Note that as the object that your code is in is a NSObject you can call methods on the object itself that are part of the NSObject protocol. So you can do this to run a method with a delay:
Code:
my performSelector_withObject_afterDelay_("loop", missing value, 1.0)
This will call the AppleScript "method" loop after 1.0 seconds and not repeat. Note that this loop was declared as:
Code:
on loop
<code here>
end loop
Note the lack of _
And that's about all I know! Is anyone else using this?