0

Possible Duplicate:
NSTimer doesn't stop

I hope to stop 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

Community
  • 1
  • 1
arachide
  • 8,006
  • 18
  • 71
  • 134
  • As a rule of thumb, you should never retain a reference which is not yours. References created without using alloc/new aren't yours so don't retain nor release them. – HyLian Feb 01 '11 at 09:05

1 Answers1

0

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

Tom van der Woerdt
  • 29,532
  • 7
  • 72
  • 105