开发者

can not stop NSTimer [duplicate]

开发者 https://www.devze.com 2023-02-08 08:18 出处:网络
This question already has answers here: Closed 10 years ago. Possible Duplicate: NSTimer doesn't stop
This question already has answers here: Closed 10 years ago.

Possible Duplicate:

NSTimer doesn't stop

I hope to st开发者_高级运维op a running NSTimer, below are my codes:

timer=[[NSTimer scheduledTimerWithTimeInterval:10       
       target:self
     selector:@selector(timerFired:)
     userInfo:nil
      repeats:NO] retain];

the function that stops the timer

-(void)stopTimer;
{

  [timer invalidate];
  [timer release];
   timer = nil;

}

But I found that even I called 'stopTimer', the timer did not stop and 'timerFired' would be triggered.

Welcome any comment

Thanks

interdev


Don't retain it, don't release it.

0

精彩评论

暂无评论...
验证码 换一张
取 消