Search code examples
iphoneobjective-cnstimer

Correct way to release NSTimer?


What is the correct way to release a NSTimer in my dealloc method ? It was created with the following code ?

-(void)mainTimerLoop {

     mainTimer = [NSTimer scheduledTimerWithTimeInterval:1/10
                                                  target:self 
                                                selector:@selector(gameLoop) 
                                                userInfo:nil
                                                 repeats:YES];
}

Thanks


Solution

  • you have a really good answer about NSTimer here How do I use NSTimer? there they talk about stoping a repeating NSTimer doing

    [myTimer invalidate];