Just converted a project to ARC and am now getting a EXEC_BAD_ACCESS after I dismiss a UIActionsheet, it was previously working and I am unsure if this is even ARC related. Zombies is enabled but showing me nothing and I tried instuments and it also gave me nothing.
This is presented in a modal view controller, case 0, the quit button works fine but the other two give me the bad access error.
This is my first conversion to ARC, am I missing something here?
Action sheet Creation:
-(IBAction)quitPressed:(id)sender {
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Quit This Game?" delegate:self cancelButtonTitle:@"Keep Playing" destructiveButtonTitle:@"Quit" otherButtonTitles:@"Quit and Reveal Answers",nil];
[sheet showInView:self.view];
}
Action sheet delegate:
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
switch (buttonIndex) {
case 0: //quit
[self dismissViewControllerAnimated:NO completion:^{
[self.delegate quitGame];
}];
break;
case 1: //quit and reveal
NSLog(@"reveal");
break;
case 2: //cancel
NSLog(@"cancel");
break;
default:
break;
}
}
Thanks everyone for the help. I found the problem when I ran the project under xcode 4.5. It gave a compile error:
switch case is protected in scopeI wasn’t getting that error in xcode 4.3
It was solved in this thread When converting a project to use ARC what does "switch case is in protected scope" mean?
I wrapped each case in curly brackets and the problem has been fixed.