NSTimer只執行一次的問題

今天犯的問題太二了,oop

NSTimer spa

應該使用 get

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

結果錯用成了class

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

fire以後,結果發現程序只執行了一次。bug

太囧了,害我花了20分鐘看bug。程序

 

timer本質是須要加入到runloop中的,這也是形成使用後者只執行一次的緣由。im

 

信心點,謹記。loop

相關文章
相關標籤/搜索