NSTimer多线程记录

测试了NSTimer的timerWithTimeInterval和scheduledTimerWithTimeInterval方法。在主线程下,scheduled方法会将timer加入runloop并执行定时器方法,timerWithTimeInterval不会,需要手动加入runloop。子线程情况下,可以将NSTimer对象加入runloop,再执行[[NSRunLoop currentRunLoop] run];,或者直接执行[timer fire];(不做runloop addTimer的操作也可以)。

你可能感兴趣的:(NSTimer多线程记录)