Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xcodeNewbie

macrumors member
Original poster
Jul 1, 2011
65
0
My navigation based app is giving me a very strange memory access error. In my root view controller I have the following code:
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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.