if([timer isValid]) // << breakpoint here
{
NSLog(@"Timer Valid");
}
timer = [NSTimer scheduledTimerWithTimeInterval:[timeinterval intValue] target:self selector:@selector(PlayDelaySound) userInfo:nil repeats:NO];
当 timer
未被调度时,该函数第一次正常运行。但是,对于后续调用,在调试时,控制台会向我提供记录单步执行的日志(如下所示)。然后给出 sigabrt。
有什么帮助吗? 谢谢
日志
Single stepping until exit from function objc_msgSend,
which has no line number information.
warning: Remote failure reply: E37
Single stepping until exit from function objc_msgSend,
which has no line number information.
warning: Remote failure reply: E37
最佳答案
也许您缺少一个retain
?
像这样:
timer = [[NSTimer scheduledTimerWithTimeInterval:[timeinterval intValue] target:self selector:@selector(PlayDelaySound) userInfo:nil repeats:NO]
retain];
更新:因为如果你不保留,计时器实例可能会在某个时候被释放,并且你对 isValid
的调用会导致崩溃。
关于iphone - NSTimer 可有效生成 sigabrt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8447250/