【发布时间】:2012-09-05 15:33:42
【问题描述】:
刚刚将一个项目转换为 ARC,在我关闭 UIActionsheet 后现在得到一个 EXEC_BAD_ACCESS,它以前可以工作,我不确定这是否与 ARC 相关。 Zombies 已启用,但什么也没显示,我尝试了仪器,但它也没有给我任何东西。
这是在模态视图控制器中显示的,案例 0,退出按钮工作正常,但其他两个给我错误的访问错误。
这是我第一次转换为 ARC,我在这里遗漏了什么吗?
操作表创建:
-(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];
}
行动表委托:
-(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;
}
}
【问题讨论】:
-
崩溃在哪一行?
-
在委托方法中放一个断点并报告它崩溃的地方
-
switch 语句的右大括号。
-
您的委托是
strong属性吗? -
亚当,你是说 UIActionSheetDelegate 吗?委托是我在其中呈现操作表的视图控制器,它没有在任何地方声明为属性。它由故事板呈现,我将不得不进一步研究。
标签: iphone objective-c xcode automatic-ref-counting exc-bad-access