• 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
Re: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate


  • Subject: Re: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate
  • From: Uli Kusterer <email@hidden>
  • Date: Fri, 26 May 2006 13:22:30 +0200

Am 26.05.2006 um 08:52 schrieb JongAm Park:
I would like to terminate a thread when an application program quits.
So, I tried checking when the "Quit" is invoked. One simple approach is to set a flag when applicationWillTerminate: or applicationShouldTerminate is invoked.
I don't know which one is called first. So I put NSLog() into each method.
It turned out that applicationShouldTerminated is called first.

Don't do clean-up in applicationShouldTerminate. applicationShouldTerminate is a method that asks you whether it's OK to quit the application right now. Doing anymore than what's needed for that is trouble. Apple may change AppKit to call this and only if you agree the app may quit they may test for more complex cases that could keep your app from quitting.


So, nothing says that you're guaranteed that your application quits when you return YES from applicationShouldTerminate.

You should always use applicationWillTerminate, because by definition this is called whenever your app is really in the process of quitting.

If you clean up in applicationShouldTerminate, your app may not quit after all, and it will be in a state between life and death. Not a good user experience.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >[Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate (From: JongAm Park <email@hidden>)

  • Prev by Date: Re: Virtual folder
  • Next by Date: Re: Newbie Q : Not-so-simple encoding&decoding example
  • Previous by thread: Re: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate
  • Next by thread: problem During Line drawing.
  • Index(es):
    • Date
    • Thread