我的应用程序崩溃并出现 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 应用程序进行通信。