Wilcox Development Solutions Blog

Sometimes Ya Gotta Look At It Differently...

September 05, 2003

So I’ve been having problems with AppleScript Studio. A whole lot of problems, actually. And it all started when I tried to put a new component on my application… I had to (or thought I had to) make popups that didn’t have borders. You can’t do that in InterfaceBuilder because, well, you can’t. So I have to do it through code. No big deal, I thought - there’s a bordered property for buttons, and it all works out.

Nope. Try as I might I for some reason couldn’t get a hold of the popup - I couldn’t put it in a variable. Now this is really really wierd, but hey, it’s AppleScript Studio, so you expect some wierdness sometimes.

I could however hardcode the names of the popups and have it work. At least, I think it worked.

Anyway, I had this brilliant idea that I shouldn’t try to use AppleScript to do it, but to use Objective-C and Cocoa - to pretend that my ASK app was just an Objective-C app.

So I wired everything up in InterfaceBuilder, created my Outlets.. and it worked. All of it. It even works with less code than the AppleScript version would have taken (if it had worked at all) because I had closer access to my data store (a plist that contained a dictionary).

So instead of at least 300-500 lines of AppleScript (interface building + getters/setters to talk to an Objective-C class + other applescript work-arounds), I did it with 200 lines of Objective-C. It works much nicer than it would in AppleScript, and it’s probably a lot faster too.

I use AppleScript to take care of some of the GUI - to pass my Objective-C code the name of the object that we’re talking about, and the value they selected. Pop that into a dictionary to store, and retrieve it when we need to display - these latter things are done with Objective-C. What I have learned from this experience:

  1. Applescript is a great glue language, but sometimes doesn’t work that great as being the bricks-and-mortar of an application
  2. Although it’s somewhat verbose at times
  3. Sometimes it’s easier to just do it in Objective-C
  4. And Calling Objective-C from Applescript is pretty much braindead

Instead of totally dreading the implementation, it became something I did in a day. It’s not entirely finished up - but it’s 90% done, I’d say.


Written by Ryan Wilcox Chief Developer, Wilcox Development Solutions... and other things