Since AppleScript Editor now supports adding Cocoa and WebKit functions, I suspect a lot of AppleScripters would like to learn more about how to do this. Well, at least I do.
Can someone point me in the direction of a tutorial or some sample script code? Since my experience with Objective-C is close to zero, I would like to stick to some basic stuff and perhaps learn how to use new UI elements in my AppleScripts.
Well, unless I am mistaken, you will have to add new UI elements programatically, since there is no Interface builder-like part to AS editor. Not that hard, but a big step from what you had in standard AppleScript. I would reccomend instead to learn AppleScriptObjC within Xcode, you will then have access to not only interface builder but also to connections and a lot of easy and powerful functions.
I think it’s nice they added the possibility to do ASOC with AS editor, but for anything but simple UI elements, I don’t see the time spent learning doing all that programatically when you can do it visually with Xcode 4.
An excellent resources to start learning ASOC (either in AS editor or Xcode) is Shane Stanley’s book. I think you’ll find it in the ASOC forums with a simple search. It will definitely push you in the right direction.
If you need some example still on ASOC in AS editor, I think that on www.macosxautomation.com there is a few examples available. Not sure about the web site address though, check the recent entries in the ASOC forums, Shane Stanley posted something recently.
Browser: Safari 6533.18.5
Operating System: Mac OS X (10.6)
You can build UI programmatically, but it is a bit challenging. If you download the samples at macosxautomation.com, one of them has code that builds a window with progress bar this way. It does it in a separate file, so you can add it to your apps. If you have the patience, you can do something similar. I know of at least one person doing this, and he says he’s having a ball. (But it’s not for me, I must say…)
For most people, I suspect Cocoa-based apps written outside Xcode are going to be more about using the non-UI features of Cocoa.
<shameless_plug>Either way, you might also want to have a look at AppleScriptObjC Explorer 2. It gives you the ability to build Cocoa-based apps like ASE in Lion, but it also makes it easier by incorporating logging (and more).<shameless_plug>
Thanks to the both of you!
Shane I bought your book instantly. Can’t wait to get started!
A nib file is an XML based interface file. So when you think it’s challenging, create an interface with interface builder, then open it in an xml or text editor and look at all the properties that needs to be set. Then use that information to program your interface. Nothing tricky or challenging about that, only costs time compared when loading a nib file.