Re: ARC dealloc best pratice
Re: ARC dealloc best pratice
- Subject: Re: ARC dealloc best pratice
- From: Jonathan Mitchell <email@hidden>
- Date: Fri, 06 Feb 2015 20:06:01 +0000
> On 6 Feb 2015, at 17:34, Kyle Sluder <email@hidden> wrote:
>
> 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.
>
I agree that dealloc is far from perfect. What it does have going for it is ubiquity and reliability.
In also implement a -dispose method that I trigger from -windowWIllClose.
This cascades down the view controller hierarchy but needs a bit of glue of course.
> Removing observers, unbinding, unregistering notifications, and timer
> invalidation all happens in -viewWillMoveToWindow: or another similar
> place.
-viewWillMoveToWindow: can called a lot if a view is repeatedly added and removed from the window view hierarchy.
It would also need hooked up to the view controller to be actually useful.
To be honest the “other place” doesn’t generically exist in my experience.
Hence -dealloc and -dispose.
Jonathan
_______________________________________________
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