Re: Cocoa, iTunes, AppleScript - performance issue
Re: Cocoa, iTunes, AppleScript - performance issue
- Subject: Re: Cocoa, iTunes, AppleScript - performance issue
- From: Matt Neuburg <email@hidden>
- Date: Thu, 13 Sep 2007 12:48:02 -0700
- Thread-topic: Cocoa, iTunes, AppleScript - performance issue
On Thu, 13 Sep 2007 03:11:13 -0500, Steve Cronin <email@hidden>
said:
>Folks;
>
>I have a set of applescripts compiled into a .scpt resource which I
>deploy as part of an application.
>I have several utility type scripts which I call using something like
>this:
>
>NSDictionary *errorDict;
>NSAppleEventDescriptor *thisResult;
>NSAppleScript *myAppleScriptUtilities = [[NSAppleScript alloc]
>initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]
>pathForResource:@"ASUtilities" ofType:@"scpt"
>inDirectory:@"Scripts"]] error:nil];
>NSString *str = [myOSXUtilities launchApplication:@"com.apple.iTunes"];
>if ([str isEqualToString:@"True"]) {
> thisResult = [myAppleScriptUtilities executeAppleEvent:[self
>callSub:@"applyGoodnessToTunes" params:
> [NSAppleEventDescriptor descriptorWithString:theGoodness],
>[NSAppleEventDescriptor descriptorWithString:trackID], nil]
>error:&errorDict];
>
>I have been pretty happy with this setup - I have several different
>scripts (Finder & Mail) working.
>Now I have begun to tinker with iTunes.
>
>I have logging enabled in the applescripts so that I can debug and
>then later so the customer can help me debug.
>
>I have a simple script which writes some metadata to selected tracks:
> set startTime to (current date)
> my writeToLog("Tunes", "-- NEW SESSION --")
> ...
> set pidC to length of myPIDList
> repeat with j from 1 to pidC
> tell application "iTunes"
> my writeToLog("Tunes", "talking to iTunes - track count: " & pidC
>as text)
> set oldfi to fixed indexing
> set fixed indexing to true
> my writeToLog("Tunes", "iTunes fixed indexing set ")
> ...
> set fixed indexing to oldfi
> end tell
> end repeat
> set deltaTime to (current date) - startTime
> my writeToLog("TagTunes", "ready to return - total time: " &
>(deltaTime as text) & " secs")
>
>
>Now, this snippet rocks when testing in Script Editor.
>
>BUT when I run my Cocoa app and call out as above here is actual data
>from the log:
>Thursday, September 13, 2007 2:54:47 AM -- NEW SESSION --
>Thursday, September 13, 2007 2:54:47 AM talking to iTunes - track
>count: 5
>Thursday, September 13, 2007 2:54:47 AM iTunes fixed indexing set
>Thursday, September 13, 2007
>2:54:47 AM top of loop -- track
>pid: 93DF7AD675F07E3C
>Thursday, September 13, 2007
>2:55:11 AM track pid access
>completed: 93DF7AD675F07E3C
You're not supplying enough information. The long delay is between the "top
of loop" log message and the "track pid access completed" message. But your
code, as shown, does not generate any "top of loop" or "track pid access
completed" message so it's impossible to guess what your AppleScript code
was doing in the meantime. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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