Trying to understand NavigationController retain count for ViewControllers on its stack
Posted
by sharkan
on Stack Overflow
See other posts from Stack Overflow
or by sharkan
Published on 2010-04-29T10:53:23Z
Indexed on
2010/04/29
10:57 UTC
Read the original article
Hit count: 309
I have an UITableViewController as the rootViewController for my navigatorController. When I press a table cell I do the following:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MessageHistory *msg = (MessageHistory *)[[self fetchedResultsController]objectAtIndexPath:indexPath];
ConversationViewController *chatController = [[ConversationViewController alloc]initWithNibName:@"ConversationView" bundle:nil andUser:msg.user];
[self.navigationController pushViewController:chatController animated:YES];
[chatController release];
But when I'm returning from the chatController (using the back button on the navbar) I get “EXC_BAD_ACCESS”
commenting
//[chatController release];
solves the problem. How? I thought when pushing to the navigationController adds a retain count and when pop from it release it?
Also I believe if I'm not including the release after pushing to the navcontroller I'm generating a leak.
Any idea what's happening here?
© Stack Overflow or respective owner