Re: How to access iTunes using cocoa
Re: How to access iTunes using cocoa
- Subject: Re: How to access iTunes using cocoa
- From: Matt Neuburg <email@hidden>
- Date: Tue, 26 Jan 2010 10:17:49 -0800
- Thread-topic: How to access iTunes using cocoa
On or about 1/26/10 9:41 AM, thus spake "Paul Sanders"
<email@hidden>:
> Should I be scared of the 'false timeout' bug?
You should if you're doing the kind of thing that triggers it. Looping in
NSAppleScript over many tracks, you're almost certain to hit it. But the
same thing is likely to happen even with the Scripting Bridge. On the other
hand, appscript in all its flavours has now worked around it.
http://db.tidbits.com/article/10643
> Mostly I just want to add
> tracks to the iTunes Music Library, although an efficient way to find a track
> by artist and title would be nice - scanning large libraries in AppleScript is
> very slow.
Well, everything depends upon (1) what you mean by "large", (2) what you
mean by "scan", and (3) what language you use. NSAppleScript is your slowest
choice because it slows way down as you loop and access memory (such as
lists). Scripting Bridge and objc-appscript do all the heavy lifting in
Objective-C and just throw Apple events at the target, so they are
inherently much faster, and your bottlenecks are then your choice of Apple
event and how long the target takes to process each Apple event. There is
almost always a way to be faster but it may take some experiment and
tweaking. See my comments on this point in my iTunes "Orphans" example for
appscript (it uses rb-appscript, which is Ruby; I would expect an
Objective-C version might be faster):
http://www.apeth.com/rbappscript/10examples.html#orphans
By the way, another nice thing I forgot to mention about objc-appscript is
that it can easily be run in a background thread, so even if your operation
*is* time-consuming (because the bottlenecks I mentioned above are
unavoidable), the user is not necessarily oppressed by this fact. m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden