我收到了来自[NSDate timeIntervalSinceReferenceDate]
的奇怪行为。exc_bad_access on [NSDate timeIntervalSinceReferenceDate]
我有以下功能:
-(void) insertRow{
NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate];
if (timeNow - secondsSinceTableViewScroll <0.5){
[self insertRow];
return;
}
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:[self.itemsToFollow count] - 1];
[self.tableView insertSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
}
这从ASIHTTPRequest requestFinished
。如果一个回调,我把一个断点在代码中,它工作正常。如果我只是尝试运行的代码,我上线得到exc_bad_access
:
NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate];
secondsSinceTableViewScroll
是在头部声明,并设置这样的伊娃:
secondsSinceTableViewScroll = [NSDate timeIntervalSinceReferenceDate];
任何想法,为什么我在没有断点时获得exc_bad_access?
感谢
只有我能找到
我被检查这样的时间件事:
-(void) insertRow{
end = [NSDate timeIntervalSinceReferenceDate];
if(end-start < 0.05){
[self insertRow];
return;
}
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:[self.itemsToFollow count] - 1];
[self.tableView insertSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
}
我敢肯定的地方它说你不能有背靠背timeIntervalSinceReferenceDate的调用,这就是为什么它崩溃了(这种递归循环反正是一个非常糟糕的主意)。
因此,使用while循环,或更好的NSTimer。
感谢您的帮助,但
我把钱它是一个红色的鲱鱼!上面的代码看起来很好。其他地方的某个地方正在导致访问不良。你运行分析仪吗?僵尸是否启用?如果他们不放弃任何东西,那么现在是时候在乐器中进行一些泄漏分析。 –
+1在StackOverflow上发布实际堆栈溢出问题 –