[英]Why am I getting an EXC_ARITHMETIC error in iOS app?
My app is crashing and getting an EXC_ARITHMETIC error and I don't know why. 我的应用崩溃了,并得到了EXC_ARITHMETIC错误,我不知道为什么。 Here is where the error is happening: 这是发生错误的地方:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); //ERROR IS HERE
[pool release];
return retVal;
}
The error happens when I click a button in the app, it's hooked up in my ViewController.m file like this: 当我单击应用程序中的按钮时,就会发生错误,该错误将其连接到ViewController.m文件中,如下所示:
- (IBAction)btnPressed:(UIButton *)sender {
[self btnPressed];
}
Which calls this code from the same file: 哪个从同一文件调用此代码:
- (void)btnPressed {
NSString *strInfo = [[NSString alloc] initWithString:@"Test Info. \r\n"];
NSData *dataInfo = [strInfo dataUsingEncoding:NSUTF8StringEncoding];
[strInfo release];
[socket writeData:dataInfo withTimeout:-1 tag:1];
}
The btnPressed is also called when the app loads and it DOES NOT produce an error. 当应用程序加载且不产生错误时,也会调用btnPressed。 As well if I add a breakpoint to the [self btnPressed];
同样,如果我向[self btnPressed];
添加一个断点[self btnPressed];
line then when I click the button in the app it works, stops at the breakpoint and when I click 'continue program execution' it works without error as well. 行,然后当我单击应用程序中的按钮时,它会在断点处停止,并且当我单击“继续程序执行”时,它也会正常工作,并且不会出现错误。
Note: I'm using CocoaAsyncSocket to communicate with a Cocoa app. 注意:我正在使用CocoaAsyncSocket与Cocoa应用程序通信。
这似乎只是iOS 5 sim的问题,在iOS 4.3中可以正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.