美文网首页
NSTimer多线程记录

NSTimer多线程记录

作者: swindler022 | 来源:发表于2019-03-04 21:16 被阅读0次

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

    相关文章

      网友评论

          本文标题:NSTimer多线程记录

          本文链接:https://www.haomeiwen.com/subject/sjuwuqtx.html