My navigation based app is giving me a very strange memory access error. In my root view controller I have the following code:
If I tap the first tab, it takes me to the WordViewController, no problem. If I tap the second tab, it takes me to the CategoriesController, no problem. If I got to WordViewController, go back to my RootView, and then try to go to the CategoriesController, it crashes with an EXE_BAD_ACCESS error. I turned on NSZombie and figured out that when I try to push the CategoriesController, for some reason it's trying to send a message to the old, deallocated WordViewController, before it shows the CategoriesController. Why is this happening?
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0) {
WordController *controller = [[[WordController alloc] init] autorelease];
controller.title = @"All Words";
controller.words = [[self appDelegate] words];
controller.type = WordTypeAll;
[self.navigationController pushViewController:controller animated:YES];
}
if (indexPath.row ==1) {
CategoriesController *controller = [[[CategoriesController alloc] init] autorelease];
[self.navigationController pushViewController:controller animated:YES];
}
}
If I tap the first tab, it takes me to the WordViewController, no problem. If I tap the second tab, it takes me to the CategoriesController, no problem. If I got to WordViewController, go back to my RootView, and then try to go to the CategoriesController, it crashes with an EXE_BAD_ACCESS error. I turned on NSZombie and figured out that when I try to push the CategoriesController, for some reason it's trying to send a message to the old, deallocated WordViewController, before it shows the CategoriesController. Why is this happening?