NSTimer只执行一次的问题

今天犯的问题太二了,

NSTimer 

应该使用 

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;

结果错用成了

+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)yesOrNo;

fire之后,结果发现程序只执行了一次。

太囧了,害我花了20分钟看bug。

 

timer本质是需要加入到runloop中的,这也是造成使用后者只执行一次的原因。

 

信心点,谨记。

posted @ 2013-10-17 19:27  Jun Wang  阅读(881)  评论(0编辑  收藏  举报