我试图在我的 XML 解析类中有一个带有“YES”和“NO”两个选项的 UIAlertView。单击其中一个选项后,我只会收到 EXC_BAD_ACCESS 错误。这是我的代码:
.m 文件:
-(void)doneParsing
{
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"My Alert"
message:@"Do you want to continue?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"No", @"Yes", nil];
[myAlert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"user pressed Button Indexed 0");
// Any action can be performed here
}
else
{
NSLog(@"user pressed Button Indexed 1");
// Any action can be performed here
}
}
.h 文件
@interface ArsivNoCheck : UIViewController <UIAlertViewDelegate>
堆栈跟踪:
Stack trace : (
0 TPAO Arastirma 0x0006de86 -[ArsivNoCheck doneParsing] + 486
1 libobjc.A.dylib 0x014ae6b0 -[NSObject performSelector:withObject:] + 70
2 Foundation 0x00eda765 __NSThreadPerformPerform + 327
3 CoreFoundation 0x01f3bf3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
4 CoreFoundation 0x01f3b96f __CFRunLoopDoSources0 + 239
5 CoreFoundation 0x01f5e734 __CFRunLoopRun + 964
6 CoreFoundation 0x01f5df44 CFRunLoopRunSpecific + 276
7 CoreFoundation 0x01f5de1b CFRunLoopRunInMode + 123
8 GraphicsServices 0x021f07e3 GSEventRunModal + 88
9 GraphicsServices 0x021f0668 GSEventRun + 104
10 UIKit 0x003deffc UIApplicationMain + 1211
11 TPAO Arastirma 0x0000244d main + 141
12 TPAO Arastirma 0x00002375 start + 53
)
BT结果
* thread #1: tid = 0x1f03, 0x014ac09b libobjc.A.dylib`objc_msgSend + 15, stop reason = EXC_BAD_ACCESS (code=1, address=0xe13e9e76)
frame #0: 0x014ac09b libobjc.A.dylib`objc_msgSend + 15
frame #1: 0x007d20bc UIKit`-[UIAlertView(Private) _buttonClicked:] + 294
frame #2: 0x014ae705 libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 77
frame #3: 0x003e22c0 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96
frame #4: 0x003e2258 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
frame #5: 0x004a3021 UIKit`-[UIControl sendAction:to:forEvent:] + 66
frame #6: 0x004a357f UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
frame #7: 0x004a26e8 UIKit`-[UIControl touchesEnded:withEvent:] + 546
frame #8: 0x00411cef UIKit`-[UIWindow _sendTouchesForEvent:] + 846
frame #9: 0x00411f02 UIKit`-[UIWindow sendEvent:] + 273
frame #10: 0x003efd4a UIKit`-[UIApplication sendEvent:] + 436
frame #11: 0x003e1698 UIKit`_UIApplicationHandleEvent + 9874
frame #12: 0x021f1df9 GraphicsServices`_PurpleEventCallback + 339
frame #13: 0x021f1ad0 GraphicsServices`PurpleEventCallback + 46
frame #14: 0x01f2dbf5 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
frame #15: 0x01f2d962 CoreFoundation`__CFRunLoopDoSource1 + 146
frame #16: 0x01f5ebb6 CoreFoundation`__CFRunLoopRun + 2118
frame #17: 0x01f5df44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #18: 0x01f5de1b CoreFoundation`CFRunLoopRunInMode + 123
frame #19: 0x021f07e3 GraphicsServices`GSEventRunModal + 88
frame #20: 0x021f0668 GraphicsServices`GSEventRun + 104
frame #21: 0x003deffc UIKit`UIApplicationMain + 1211
frame #22: 0x0000204d TPAO Arastirma`main(argc=1, argv=0xbffff394) + 141 at main.m:16
frame #23: 0x00001f75 TPAO Arastirma`start + 53