将应用程序部署到设备时,程序将在几个周期后退出并出现以下错误:
Program received signal: "EXC_BAD_ACCESS".
Run Code Online (Sandbox Code Playgroud)
该程序在iPhone模拟器上运行没有任何问题,只要我逐步执行一个指令,它也将调试和运行.一旦我让它再次运行,我就会EXC_BAD_ACCESS发出信号.
在这种特殊情况下,它恰好是加速度计代码中的错误.它不会在模拟器中执行,这就是它没有抛出任何错误的原因.但是,它会在部署到设备后执行.
这个问题的大部分答案都是针对一般EXC_BAD_ACCESS错误的,所以我会把这个问题保留为可怕的Bad Access错误.
EXC_BAD_ACCESS通常由于非法内存访问而被抛出.您可以在下面的答案中找到更多信息.
你EXC_BAD_ACCESS以前遇到过这个信号吗,你是怎么处理它的?
我试图在另一个视图以模态方式呈现后直接显示模态视图(第二个是出现的加载视图).
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// Show load
LoadViewController *loader = [[LoadViewController alloc] init];
[self presentModalViewController: loader animated:NO];
[loader release];
}
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我得到一个"程序接收信号:"EXC_BAD_ACCESS"." 错误.
堆栈跟踪是:
0 0x30b43234 in -[UIWindowController transitionViewDidComplete:fromView:toView:]
1 0x3095828e in -[UITransitionView notifyDidCompleteTransition:]
2 0x3091af0d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:]
3 0x3091ad7c in -[UIViewAnimationState animationDidStop:finished:]
4 0x0051e331 in run_animation_callbacks
5 0x0051e109 in CA::timer_callback
6 0x302454a0 in CFRunLoopRunSpecific
7 0x30244628 in CFRunLoopRunInMode
8 0x32044c31 in GSEventRunModal
9 0x32044cf6 in GSEventRun
10 0x309021ee in UIApplicationMain
11 0x00002154 in main at main.m:14
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我完全难过了!加载视图为空,因此肯定没有任何事情导致错误.是否与在同一个事件循环中以模态方式启动2个视图有关? …
我创建了一个应该运行的应用程序,直到我停止它.它基本上做的是从连接的另一个设备获取一些数据NSURLConnection,并定期使用该数据发送到服务器,并定期从服务器读取数据,并使用图形将该数据可视化NSXMLParser.
我运行仪器来检查分配和泄漏.完全没有泄漏.内存监视器显示一致的5.2 MB.Objectalloc图是稳定的,objectallo的净字节是480000,#net是6400左右.
它在大约10~15小时后坠毁.所以我添加了断点malloc_error_break.现在,EXC_BAD_ACCESS大约12小时后,我在调试器控制台上出现" "错误.
任何的想法?
一个可疑的部分是SENDING数据.
- (void) sendDataToServerWithX:(float)x Y:(float)y{
NSAutoreleasePool *uiUpdatePool = [[NSAutoreleasePool alloc] init];
NSString *urlString = [[NSString alloc] initWithFormat:@"http://www.url.com/save_data.php?user=user1&x=%f&y=%f", x, y];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) { NSLog(@"sending success"); }
//else { }
NSLog( @"data sent.");
[urlString release];
[theConnection release];
[uiUpdatePool drain];
}
另一个可疑部分是阅读数据:
- (void) readCurrentDataFromServer: (NSTimer *) timer {
NSAutoreleasePool *uiUpdatePool = …Run Code Online (Sandbox Code Playgroud)