Nutter
Oct 8, 2006, 07:56 PM
I'm a fairly newb Cocoa programmer looking to send Apple Events to iTunes (and receive responses in some cases).
As I understand it, I have four options:
Use the Carbon routines for this, which look really scary.
Use NSAppleScript to generate Apple Events from AppleScripts. AFAIK I won't be able to use compiled scripts in cases where I want to use variables in my App as part of the script, so performance will suffer.
Use NSAppleEventDescriptor with NSAppleScript to generate Apple Events in code. I'm not sure how difficult this would be.
Use a third-party Objective-C wrapper, such as this:
http://homepage.mac.com/nathan_day/pages/s...plescriptobject (http://homepage.mac.com/nathan_day/pages/source.xml#ndapplescriptobject)
Now, it seems to me that option 4 is the easiest way to do this with reasonable performance, as it would let me effectively pass variables into compiled scripts. However, I'm reluctant to bung someone else's code in my App without properly considering the alternatives. I'm also worried that I'd be able to get better performance by building the events programmatically, I'm just not sure I'm up to it yet.
To top it all off, I suspect that I'll need to send the events asynchronously to avoid bringing my GUI to a grinding halt, and keep it from crashing if (when) iTunes does. Is that even possible if I'm using high-level code that works from an AppleScript?
Does anyone have any advice?
As I understand it, I have four options:
Use the Carbon routines for this, which look really scary.
Use NSAppleScript to generate Apple Events from AppleScripts. AFAIK I won't be able to use compiled scripts in cases where I want to use variables in my App as part of the script, so performance will suffer.
Use NSAppleEventDescriptor with NSAppleScript to generate Apple Events in code. I'm not sure how difficult this would be.
Use a third-party Objective-C wrapper, such as this:
http://homepage.mac.com/nathan_day/pages/s...plescriptobject (http://homepage.mac.com/nathan_day/pages/source.xml#ndapplescriptobject)
Now, it seems to me that option 4 is the easiest way to do this with reasonable performance, as it would let me effectively pass variables into compiled scripts. However, I'm reluctant to bung someone else's code in my App without properly considering the alternatives. I'm also worried that I'd be able to get better performance by building the events programmatically, I'm just not sure I'm up to it yet.
To top it all off, I suspect that I'll need to send the events asynchronously to avoid bringing my GUI to a grinding halt, and keep it from crashing if (when) iTunes does. Is that even possible if I'm using high-level code that works from an AppleScript?
Does anyone have any advice?
