Iphone NSTimer在生成sigabrt时有效

Iphone NSTimer在生成sigabrt时有效,iphone,objective-c,ios,xcode,sigabrt,Iphone,Objective C,Ios,Xcode,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: Re

也许您缺少了一个
保留

像这样:

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

更新:因为如果您没有保留,计时器实例可能会在某个时候被释放,并且您对
的调用是有效的
会导致崩溃。

可能您缺少
保留

像这样:

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

更新:因为如果你不保留,计时器实例可能会在某个时候被释放,而你对
的调用是有效的
会导致崩溃。

你说的“sigbart”是指sigbart,对吗?你说的“sigbart”是指sigbart,对吗?谢谢..这就解决了问题。我现在应该在dealloc中发送一条释放消息,对吗?是的。您还应该在创建新版本之前发送一个版本。或者您可以创建一个属性retain,当您执行
self.timer=…
时,它将自动处理第二部分,您只需执行
self.timer=nil在你的dealloc中。我不需要新的。。。基本上,我在接口中创建了一个,其余的代码就在这里,所以dealloc中的计时器释放就足够了。如果这已经是一个属性,您应该编写
self.timer=…
并在
dealloc
中释放它。如果这是一个ivar,你必须在分配一个新的ivar之前释放它,并在dealloc中释放。谢谢..这就解决了它。我现在应该在dealloc中发送一条释放消息,对吗?是的。您还应该在创建新版本之前发送一个版本。或者您可以创建一个属性retain,当您执行
self.timer=…
时,它将自动处理第二部分,您只需执行
self.timer=nil在你的dealloc中。我不需要新的。。。基本上,我在接口中创建了一个,其余的代码就在这里,所以dealloc中的计时器释放就足够了。如果这已经是一个属性,您应该编写
self.timer=…
并在
dealloc
中释放它。如果这是一个ivar,您必须在分配一个新的ivar和dealloc之前释放它。
timer = [[NSTimer scheduledTimerWithTimeInterval:[timeinterval intValue] target:self selector:@selector(PlayDelaySound) userInfo:nil  repeats:NO]
         retain];