2

我收到了两份关于 Crashlytics 的崩溃报告,其中包含类似的日志,一份用于 an UIAlertView,一份用于 an UIActionSheet

Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0xa0000008

0    libobjc.A.dylib     objc_msgSend + 15
1    UIKit   -[UIAlertView(Private) _buttonClicked:] + 296
2    UIKit   -[UIApplication sendAction:to:from:forEvent:] + 72
3    UIKit   -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4    UIKit   -[UIControl sendAction:to:forEvent:] + 44
5    UIKit   -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 502
6    UIKit   -[UIControl touchesEnded:withEvent:] + 488
7    UIKit   -[UIWindow _sendTouchesForEvent:] + 524
8    UIKit   -[UIApplication sendEvent:] + 380
9    UIKit   _UIApplicationHandleEvent + 6154
10   GraphicsServices    _PurpleEventCallback + 590
11   GraphicsServices    PurpleEventCallback + 34
12 ...   CoreFoundation  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34

我正在使用 ARC,在我的代码中,我在视图控制器中分配/初始化警报视图和操作表,将委托设置为self. 我找不到问题的根源,有什么建议吗?

这是一个例子SomeViewController.m

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you sure?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Continue",nil) destructiveButtonTitle:NSLocalizedString(@"Yes", nil) otherButtonTitles:nil];
            actionSheet.delegate = self;
            [actionSheet showInView:self.view];

结束我实施(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

4

2 回答 2

2

找到这种错误的最好方法是使用NSZombieEnabled环境变量。EXC_BAD_ACCESS原因是试图访问已释放的对象。回顾这个

于 2013-05-24T13:52:48.550 回答
0

You can debug to see at which statement the exception occurs

  1. Click on 'show breakpoint navigator' on left side panel

  2. Click + button on down of panel

  3. Add exception breakpoint

  4. Done pop up

Now it will shows exception statement

于 2013-05-24T13:53:27.383 回答