Re: ARC dealloc best pratice
Re: ARC dealloc best pratice
- Subject: Re: ARC dealloc best pratice
- From: Kyle Sluder <email@hidden>
- Date: Fri, 06 Feb 2015 11:34:35 -0600
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 (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