简体   繁体   中英

EXEC_BAD_ACCESS (code=1 address=0x90000008) when switching view controllers

So, I have an app that uses a tableViewController to populate a list of different game types. When a game is selected, it performs a segue by that name.

This was working perfectly (pushing & popping correctly) until I added a stats menu for when one of the game modes finished.

Now I sometimes get a EXEC_BAD_ACCESS error when switching from the stats menu back to the tableViewController. So:

TVC ---> Game ---> Stats

Then

Stats ---> TVC

Code to switch from TVC to Game:

NSString* a = (NSString*)[games objectAtIndex:indexPath.row];
a = [a stringByReplacingOccurrencesOfString:@" " withString:@""];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self performSegueWithIdentifier:a sender:self];

Code to switch from Game to Stats Menu:

[self performSegueWithIdentifier:@"Stats" sender:self];

Code to switch from Stats Menu to TVC (Where the problem emerged):

NSArray* controllers = self.navigationController.viewControllers;
int a = [controllers count] - 1;
[self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:a-2] animated:YES];

Error in question

Link to Code

Try to analyze your code to see if there are any memory leak. It could be a cause that your application is crashing.

It looks as though apple is trying to enforce ARC now. I just downloaded the update for the 10.7 SDK and it made my program(which also contains a performSegueWithIdentifier:) super buggy and throw EXC_BAD_ACCESS on multiple issues that I had previously resolved(pre SDK update). I turned on ARC, and commented out all of my release/dealloc calls, its back to working condition. Nice how the debugger points you where they are i suppose. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM