NSTimer not firing

前端 未结 3 1289
野趣味
野趣味 2020-12-11 03:13

I have an NSTimer that I init with this code:

testTimer = [[NSTimer alloc] initWithFireDate:[new objectAtIndex:0] interval:0.0 target:self selector:@selector         


        
3条回答
  •  难免孤独
    2020-12-11 03:34

    You will have to add it to the current run loop if you use initWith.. method to create the timer object.

    NSRunLoop * theRunLoop = [NSRunLoop currentRunLoop];
    [theRunLoop addTimer:testTimer forMode:NSDefaultRunLoopMode];
    

    Or if you would like it set up for you, use the scheduled... methods to create your timer.

提交回复
热议问题