NSTimer Not Stopping When Invalidated

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

I have the following code in my .h file:

#import 
#import 
#import 

        
7条回答
  •  日久生厌
    2021-01-05 05:55

    NSTimer is retained by NSRunLoop, so the only way I see your issue happening is if you're actually creating more than one timer and invalidating only what you have reference to.

    Example:

    if(!timer)
            timer = [NSTimer scheduledTimerWithTimeInterval:1 target:(self) selector:@selector(processTimer) userInfo:nil repeats:YES];
    

提交回复
热议问题