Please, take a look at my code bellow. This part pops top view controller (usually, the same ArticleControllerController
) from the stack (I found that the problem stays the same no matter if I pop single controller or pop to the root controller), creates new one and adds to the stack.
The problem is, that its retain count never goes to zero and so dealloc
method of ArticleControllerController
is never called leaving large amounts of various interface objects unreleased. Eventually app crashes (at least in device and at least I think this part is the main problem) because of low memory.
- (void) navigateToNewsCategoryByIndex:(int)idx {
[app.nav popViewControllerAnimated:NO]; // could be popToRootController
ArticleControllerController *ac = [[ArticleControllerController alloc] init];
ac.categoryIndex = idx;
[app.nav pushViewController:ac animated:NO];
[ac release];
NSLog(@"AC retain count: %d", [ac retainCount]); // prints 2
}
So, I guess, popViewControllerAnimated releases only one of the remaining two retains. Why? What should I look for? What can I do? Call [ac release]
two times (that would be terrible thing)?