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];
Try to analyze your code to see if there are any memory leak. It could be a cause that your application is crashing.