So my code goes like this:
ArticleControllerController *ac = [[ArticleControllerController alloc] init];
ac.categoryIndex = idx;
NSLog(@"acc retain: %d", [ac retainCount]);
[app.nav pushViewController:ac animated:NO];
NSLog(@"acc retain: %d", [ac retainCount]);
[ac release];
NSLog(@"acc retain: %d", [ac retainCount]);
And I get:
[2649:207] acc retain: 1
[2649:207] acc retain: 3
[2649:207] acc retain: 2
How to resolve this mess? I don't understand what I'm doing wrong and this part sometimes causes application crash due low memory.
Edit: related problem.
So the situation is the same as defined above, but the problem is that ArticleControllerController dealloc method never gets called.
More code:
- (void) navigateToNewsCategoryByIndex:(int)idx {
[app.nav popViewControllerAnimated:NO];
currentMode = MODE_ARTICLE;
ArticleControllerController *ac = [[ArticleControllerController alloc] init];
ac.categoryIndex = idx;
[app.nav pushViewController:ac animated:NO];
[ac release];
return ;
}
If this method gets repeated several times ArticleControllerController creates massive amounts of various interface elements, but its dealloc method never releases them (retain count never goes down to zero), so I think here lies the memory-crash problem I am trying to resolve for a couple of days now.
What's up with that? Can I do something more to resolve this?