iPhone - NSTimer not repeating after fire

前端 未结 8 1809
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 16:14

I am creating and firing a NSTimer with:

ncTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                           target:sel         


        
8条回答
  •  鱼传尺愫
    2021-02-19 16:31

    You can also copy your code inside this block, which inserts the creation of the Timer in the main thread.

    The code will therefore remain:

    dispatch_async(dispatch_get_main_queue(), ^{
      self.ncTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                     target:self selector:@selector(handleTimer:) userInfo:nil repeats: YES];
    });
    

提交回复
热议问题