Re: NSApplication delegate not released on quit?
Re: NSApplication delegate not released on quit?
- Subject: Re: NSApplication delegate not released on quit?
- From: Wade Tregaskis <email@hidden>
- Date: Sat, 14 Jun 2003 16:09:17 +1000
So all your singleton objects should register themselves to the
NSApplicationWillTerminateNotification to free themselves? Or a
message should be sent to classes to do it? I'm pretty sure there are
more interesting and useful things to do in your code than that. I
don't see why admitting that some "immortal" objects live until the
application dies is such a big deal. Think of it as another kind of
contract, and you're done.
This is great until you decide to use that object somewhere else, for
some other reason, and then it starts leaking...
I think this is one of the aspects the original poster was trying to
emphasize, although the counter-responses have ignored it. Portability
of your code is very important, whether you can foresee it's future
uses or not. I keep learning the hard way, even though I now write
very portable code, as old classes still keep coming back into use.
Having said that, there are cases where I'm having a hard time
imagining when they could /not/ be released. For example, consider a
static instance of your class in one of it's class methods (e.g. a
"defaultMyClass" method). That won't ever be released, and indeed it's
purpose is to probably live for the entire life of your program,
regardless of how it's used. So, if you were to explicitly destroy it
you would have to install a notification handler for
NSApplicationWillQuit (or whatever it is), and I think it's clear that
at that point that such a deallocator is redundant.
Wade Tregaskis
-- Sed quis custodiet ipsos custodes?
_______________________________________________
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.