dealloc for cleanup versus freeing memory
dealloc for cleanup versus freeing memory
- Subject: dealloc for cleanup versus freeing memory
- From: Klaus Backert <email@hidden>
- Date: Mon, 6 Aug 2007 15:31:03 +0200
Am 06.08.2007 um 09:02 schrieb Kurt Bigler:
<snip>
And dealloc is the only standard method (present in the root
class) that could conceivably be used for tear-down.
<snip>
Thanks.
-Kurt
Other methods I've found useful are:
- NSDocumentController's removeDocument
The documentation states "This method is mostly provided for
subclassers that want to know when documents close". Because the
document should be the controller of it's model object(s),
removeDocument may be the appropriate place to cleanup these model
object(s) (especially in the case when only a document is closed,
without shutting down the application).
- NSWindow's windowWillClose
This is sent by the default notification center to the window's
delegate - e.g. subclassed from NSWindowController - immediately
before an NSWindow object closes. If the delegate has an outlet
pointing to a view containing additional data structures, then here
may be the place for sending a cleanup message to the view. Above
that: If there are bindings, which are set programmatically, unbind
messages can be sent (the delegate, or some object used by it, has to
know about this, of course).
Not all applications have subclassed NSDocumentController and/or
NSWindowController, of course, as I know.
Greetings
Klaus
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden