Hi,
I've got a timer which fires when viewWillAppear method is being called and invalidates when viewDidDisappear method is being called. But after a certain amount of switching between views the timer continues firing even after it was invalidated. What's the problem?
Here is my code:
NSTimer *timer;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
timer = [NSTimer scheduledTimerWithTimeInterval: 0.2f
target: self
selector:@selector( timerAction )
userInfo:nil
repeats:YES];
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[timer invalidate];
timer = nil;
}
-(void) timerAction
{
NSLog(@"timerAction");
}