Re: dealloc not beeing called... why?
Re: dealloc not beeing called... why?
- Subject: Re: dealloc not beeing called... why?
- From: James DiPalma <email@hidden>
- Date: Tue, 9 Jul 2002 15:18:17 -0400
On Tuesday, July 9, 2002, at 10:34 AM, Development wrote:
OK, but I thought, the OS would care about the deallocation of the
object. It has the -dealloc method already built-in and whoever created
the instance of my subclasses NSObject after NIB load has to call this
-dealloc method eventually, no?!
No. Nib files present a special sort of problem to developers. Top level
objects leave nib loading with a retain count of 1 (it goes: init,
retain, retain, autorelease, autorelease).
When NSWindowControllers load nib files, they will autorelease all top
level objects when their window closes. I don't think that NSApplication
does what NSWindowController does to release top level objects when
NSApplications quit. Maybe it should, but how many applications would
raise exceptions when quiting if this behavior changed?
If not, what's the right time and where's the right place to call the
objects -dealloc method, i.e. is there a recommended way to do this? I
have to do some clean up before quitting the app...
I think calling dealloc directly is not recommended. Try
applicationWillTerminate:, NSApplicationWillTerminateNotification (both
already suggested) or maybe override NSApplication's dealloc method.
-jim
_______________________________________________
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.