Re: Can I somehow encourage the deallocation of a dismissed view controller?
Re: Can I somehow encourage the deallocation of a dismissed view controller?
- Subject: Re: Can I somehow encourage the deallocation of a dismissed view controller?
- From: G S <email@hidden>
- Date: Wed, 08 Feb 2012 19:05:36 -0800
On Wed, Feb 8, 2012 at 6:41 PM, Alex Zavatone <email@hidden> wrote:
> I'd check to see if it's already been deallocated.
>
>
Thanks Alex. I don't know which item you mean (the control or its parent
view), but I have breakpoints set in both of their dealloc methods and
those breakpoints do work. So I know the problematic control isn't getting
deallocated. If I release it three times in succession in the parent
view's dealloc method, it does get deallocated (but of course the app
crashes immediately afterward).
I have a question about this in the Apple doc:
Because outlets to elements within the nib file are typically retained,
however, even though the main view is disposed of, absent any further
action the outlets are not disposed of. This is not in and of itself a
problem—if and when the main view is reloaded, they will simply be
replaced—but it does mean that the beneficial effect of the
didReceiveMemoryWarning is reduced. To ensure that you properly relinquish
ownership of outlets, in your custom view controller class you can
implement viewDidUnload to invoke your accessor methods to set outlets to
nil.
- (void)viewDidUnload {
self.anOutlet = nil;
[super viewDidUnload];
}
It's a little ambiguous because it assumes you have properties set up for
all your outlets. I don't create properties for my outlets; I don't see
the point of creating accessors for things that don't need to be accessed
outside the object. It's just a bunch more syntax to maintain, and also
adds retention that you have to be mindful of.
So in my case, to follow the above advice, I'd be doing things like
- (void)viewDidUnload
{
_thumbStrip = nil;
[super viewDidUnload];
}
Does that still seem useful?
Thanks.
_______________________________________________
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