NSTimer Not Stopping When Invalidated

后端 未结 7 1287
情书的邮戳
情书的邮戳 2021-01-05 05:22

I have the following code in my .h file:

#import 
#import 
#import 

        
相关标签:
7条回答
  • 2021-01-05 06:04

    Its weird but invalidating passed timer reference and created timer reference worked for me.

        delayTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateDelayLable:) userInfo:nil repeats:YES];
    
        -(void)updateSendDataDelayLable:(NSTimer*)timer{
    delayValueForGNSS--;
    
                    if (delayValueForGNSSSend==0) {
                         [timer invalidate];
                         timer = nil;
                         [delayTimer invalidate];
                         delayTimer = nil;
                    }
                }
    
    0 讨论(0)
提交回复
热议问题