我正在使用Apple的Accelerometer Graph示例: http://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html
我正在将2个图表视图推送到导航控制器:
GraphViewController* graphViewController = [[GraphViewController alloc]initWithNibName:@"GraphViewController" bundle:nil];
[self.navigationController pushViewController:graphViewController animated:YES];
[graphViewController release];
图表由外部方法更新:
[motionManager startDeviceMotionUpdatesToQueue:motionQueue withHandler:^(CMDeviceMotion *motion, NSError *error) {
...
if(graphDelegate)
{
[self performSelectorInBackground:@selector(notifyGraphDelegateWithMotionEvent:) withObject:motion];
}
}
,调用
[unfiltered addX:filteredValue y:unfilteredvalue z:10];
每个图表。更新频率为每秒20次
当我从导航控制器弹出视图时,我在[super dealloc]之后得到EXC_BAD_ACCESS
-(void)dealloc
{
// Since 'text' and 'current' are weak references, we do not release them here.
// [super dealloc] will take care to release 'text' as a subview, and releasing 'segments' will release 'current'.
[segments release];
[super dealloc];
}
这是一个令人讨厌的错误,我真的不知道如何解决这样的问题。这似乎与视图被解除分配的顺序有关,因为崩溃发生在视图弹出之后。关于如何解决这类问题的任何想法?
答案 0 :(得分:1)
在调试器中设置NSZombieEnabled,MallocStackLogging和guard malloc。然后,当您的应用程序崩溃时,请在gdb控制台中输入:
(gdb) info malloc-history 0x543216
将0x543216
替换为导致崩溃的对象的地址,您将获得更有用的堆栈跟踪,它可以帮助您查明代码中导致问题的确切行。