Re: NSApplication delegate not released on quit?
Re: NSApplication delegate not released on quit?
- Subject: Re: NSApplication delegate not released on quit?
- From: Marco Scheurer <email@hidden>
- Date: Sat, 14 Jun 2003 16:12:31 +0200
On Saturday, June 14, 2003, at 08:09 AM, Wade Tregaskis wrote:
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.
Not at all, I was just pointing out that it is not wrong to allocate
and never release some resources, and giving such an example. A case
where this "symmetry" is not expected.
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.
This is exactly what I meant by singleton objects. Who cares about
disposing them?
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.
A waste of time, a complication for absolutely no benefits.
Marco Scheurer
Sen:te, Lausanne, Switzerland
http://www.sente.ch
_______________________________________________
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.