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: Alex Zavatone <email@hidden>
- Date: Wed, 08 Feb 2012 21:23:20 -0600
On Feb 8, 2012, at 9:05 PM, G S wrote:
> 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).
AHHHHH.
There you go. You gotta realize that if you release an object more than once, that WILL end up crashing, though not necessarily when you expect.
This is why I wanted to explicitly output a variable within that object to see if it's still legit.
I'm not very well schooled on the garbage collection scheme that is being used, so this is why I wanted to see "if a variable within the object still has a valid reference". If it does not, then I would expect a crash to happen after your explicit dealloc.
If garbage collection happens at a different time, then I would expect what would seem like a random crash some time after the dealloc/release, if it's getting released more than once.
Just a thought and I'm no expert in this.
> 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