NSTimer requiring me to add it to a runloop

前端 未结 6 1974
盖世英雄少女心
盖世英雄少女心 2020-12-28 16:27

I am wondering if someone can explain why dispatching back to the main queue and creating a repeating NSTimer I am having to add it to RUN LOOP for it too fire?

6条回答
  •  孤城傲影
    2020-12-28 16:51

    And here's how to add an NSTimer to a runloop:

    NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
    [runLoop addTimer:timer forMode:NSDefaultRunLoopMode];
    

提交回复
热议问题