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