Re: [Q] which arrives earlier? applicationShouldTerminate or applicationWillTerminate
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