I have tested my all viewControllers dealloc methods. And all of them getting called properly on calling popViewControllerAnimated.
But only 1 controller's dealloc method not getting called. I am not able to figure out the issue.
While pushing to that controller I have properly written following code:
AController *contr = [AController alloc]initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:contr animated:YES];
[contr release];
and when I am coming back from controller I have written :
[self.navigationController popViewControllerAnimated:YES];
This is really strange behaviour because this code is written on many controllers and its working properly.
If it's not getting called it's still alive. Try to use instruments to find it. If you use the allocations tool in instruments you should be able to find the class (by name) in a list of allocations and see if it is still alive or not. You can even see by whom (I'm pretending that classes are people) it is retained.
If dealloc is not called you might have another object that retain it.
Check that object that might use this delegate do not retain it.
Hi I know this is an old post, but this answer may help someone stuck in my position. Spent a long time trying to find out why dealloc wasn't getting called. It turned out that I was not invalidating an NSTimer in my viewWillDisappear method and hence it was holding on to the retain count.
This great blog post is a must read for people in this situation:
http://www.reigndesign.com/blog/debugging-retain-cycles-in-objective-c-four-likely-culprits/#comment-41302
I was having the similar issue;I wanted to show a UIViewController
for like 3 seconds(copyright screen). So I was essentially calling the PushViewCOntroller
and popViewController
from the main file and the dealloc
was not getting called when i was popping the view controller.
I then switched from pushViewCOntroller to
[self.navigationController presentModalViewController:copyrightView animated:NO];
and
[self.navigationController dismissModalViewControllerAnimated:NO];
and it started working.
I dont know how it can fix the issue; but it did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With