NSTimer requiring me to add it to a runloop

前端 未结 6 1950
盖世英雄少女心
盖世英雄少女心 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:35

    You could always use this method instead:

    NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(getBusLocation) userInfo:nil repeats:YES];

    This will save you a line, as it will add it to the run loop automatically.

提交回复
热议问题