On Fri, Feb 6, 2015, at 08:48 AM, Jonathan Mitchell wrote:
> So I want to have a best practice template to follow in my dealloc.
> At present the template looks like so. When I need a dealloc I paste this
> in and fill in the blanks 
> 
> - (void) dealloc
> {
>       // remove observers
> 
>       // remove any explicit bindings
> 
>       // unregister for notifications
> 
>       // set any non-weak delegates to nil (NSTableView et al)
> 
>       // invalidate any timers
> 
> }

Dealloc is too late for a lot of this stuff. I try to keep -dealloc as
pure as possible; that is, -dealloc should only be concerned with memory
management.

Removing observers, unbinding, unregistering notifications, and timer
invalidation all happens in -viewWillMoveToWindow: or another similar
place.

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to