• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?


  • Subject: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?
  • From: "email@hidden" <email@hidden>
  • Date: Wed, 8 Sep 2010 16:39:13 +0200

Hello,

This problem was introduced in Mac OS X 10.6 and has remained unsolved
ever since.

I've got a timer that polls iTunes for its player position every
second. I used to use ScriptingBridge for this task:

if ( [iTunes isRunning] ) {
   if ( [self isPlaying] ) return [iTunes playerPosition];
}
return 0;

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.

As a workaround, I tried registering an observer for NSWorkSpace's
NSWorkspaceDidTerminateApplicationNotification. As soon as I received
the notification, I would invalidate the timer to make sure its fire
method wouldn't trigger a relaunch. I also set iTunes timeout delay to
-1, just to be on the safe side.

Unfortunately this had no effect at all. A wild guess is that the
NSWorkspaceDidTerminateApplicationNotification under Snow Leopard is
sent out somewhat later than in earlier versions.

Finally I tried replacing ScriptingBridge with NSAppleScript:

currentTimeScript = [[NSAppleScript alloc] initWithSource:@"try\n\
							  if application \"iTunes\" is running then\n\
							  tell application \"iTunes\"\n\
							  if player state is not stopped then\n\
							  return player position\n\
							  end if\n\
							  end tell\n\
							  end if\n\
							  on error\n\
							  return 0\n\
							  end try"];

This yielded somewhat better results. iTunes now quits gracefully most
of the time, but is still relaunched every now and then (some users
report it still happens each and every time). Now I'm out of ideas...
What did I miss? Should I file a radar?

Ideally, I'd like a NSWorkspaceWillTerminateApplicationNotification.
But for now I just need to find a workaround. All suggestions are
welcome.

-F
_______________________________________________

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

  • Follow-Ups:
    • Re: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?
      • From: Dave Keck <email@hidden>
  • Prev by Date: Re: NSEntityMigrationPolicy subclass methods not being called
  • Next by Date: Re: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?
  • Previous by thread: Core Data and Managed Object Context Question
  • Next by thread: Re: delayed NSWorkspaceDidTerminateApplicationNotification under 10.6?
  • Index(es):
    • Date
    • Thread