为什么我在 iOS 应用程序中收到 EXC_ARITHMETIC 错误?
我的应用程序崩溃并出现 EXC_ARITHMETIC 错误,我不知道为什么。这是发生错误的地方:
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;
}
当我单击应用程序中的按钮时,就会发生错误,它在我的 ViewController.m 文件中连接如下:
- (IBAction)btnPressed:(UIButton *)sender {
[self btnPressed];
}
从同一文件调用此代码:
- (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];
}
应用程序加载时也会调用 btnPressed并且它不会产生错误。同样,如果我向 [self btnPressed];
行添加一个断点,那么当我单击应用程序中的按钮时,它会工作,在断点处停止,当我单击“继续程序执行”时,它会工作而无需错误也是如此。
注意:我使用 CocoaAsyncSocket 与 Cocoa 应用程序进行通信。
My app is crashing and getting an EXC_ARITHMETIC error and I don't know why. 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:
- (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. As well if I add a breakpoint to the [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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这似乎只是 iOS 5 sim 的问题,在 iOS 4.3 中运行良好。
This seems to be only a problem with iOS 5 sim, running fine in iOS 4.3.