Hi Dave,

Thanks for your reply.

On Wed, Sep 8, 2010 at 7:18 PM, Dave Keck <davek...@gmail.com> wrote:
>> After the release of Snow Leopard, it seems that [iTunes isRunning]
>> returns YES for a short while even after the application has quit (I
>> believe this applies to all apps, not just iTunes, but I haven't
>> confirmed this yet). As a result, my app would relaunch iTunes,
>> assuming it was still running. Not cool.
>
> I can't comment decisively on your problem with Scripting Bridge, but I
> experienced some relaunching issues with NSAppleScript when attempting to
> control an application other than iTunes. Since both NSAppleScript and
> Scripting Bridge are based on Apple events, I imagine we experienced the
> same underlying problem.

I believe you are right. Funny though that the NSAppleScript route
seems to cause fewer relaunches than ScriptingBridge.

> Anyway, I ended up using the Process Manager APIs
> to check whether the app in question was running before executing an
> AppleScript to issue commands to it.

It's worth a try. But I'm afraid it will put a heavy load on the CPU
for a timer firing every second, no?

> (It seems NSRunningApplication is the
> modern API for 10.6+.)

Do we know if this is faster than using Process Manager? Unfortunately
I need to target Mac OS X 10.5 as well (where this is not a problem),
but I suppose I could use NSSelectorFromString() to get it to compile
under the 10.5 SDK.

> /snip.../
>
> I only know enough about AppleScript to avoid it, but I believe iTunes is
> being launched necessarily for the NSAppleScript to compile.

No, this is not correct. You can compile a script without launching
the target - at least on Snow Leopard.

-F
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to