Re: NSApplication delegate not released on quit?
Re: NSApplication delegate not released on quit?
- Subject: Re: NSApplication delegate not released on quit?
- From: Sherm Pendley <email@hidden>
- Date: Fri, 13 Jun 2003 18:34:10 -0400
On Friday, June 13, 2003, at 06:05 PM, Ron Wagner wrote:
Yes, it is the cleanup I'm worried about. I have some resources that
need to be released. So when I return NSTerminateNow from
applicationShouldTerminate I can be relatively assured that the
application will quit and not get canceled from any other mechanism?
As far as I know, NSApplication can have only a single delegate, and
there's no corresponding notification for -applicationShouldTerminate:,
so technically yes, I think that you can be relatively assured that no
other mechanism will cancel the shutdown.
Speaking in terms of the intended use of the method, though, I think
that -applicationWillTerminate: is the more appropriate place for
cleanup code like you're describing.
The -applicationShouldTerminate: method is asking you a question - is
there any reason this app shouldn't be allowed to quit? In this method,
you can check for operations in progress, unsaved files, etc., and if
necessary pop up a dialog and/or sheet that reminds the user about them.
The -applicationWillTerminate: method isn't asking any questions - it's
telling you that everything has already been decided, and the app *will*
terminate. This is where you'd want to clean up resources, delete
temporary files, and so forth.
sherm--
"A well-written program is its own heaven; a poorly-written program is
its own hell."
-- The Tao of Programming
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.