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
答案 0 :(得分:4)
也许你错过了retain
?
像这样:
timer = [[NSTimer scheduledTimerWithTimeInterval:[timeinterval intValue] target:self selector:@selector(PlayDelaySound) userInfo:nil repeats:NO]
retain];
更新:因为如果您不保留,可能会在某个时间释放计时器实例,并且您对isValid
的调用会导致崩溃。