Hello Guys,
I have a problem with invalidating a NSTimer. Basically, I want to stop the timer when a user logs out.
Now the problem is, when I logout
after the updateIncidents() method is called, the application crashes with an EXC_BAD_ACCESS signal.
When the logOut method is called
before the updateIncidents() method is executed, the invalidating works fine.
My code is as follows:
In the .h file:
In the .m file:
Code:
//In the viewDidLoad() method
timer = [NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(updateIncidents:) userInfo:nil repeats:YES];
-(void)logOut {
[timer invalidate];
timer = nil;
[self.navigationController popViewControllerAnimated:YES];
}
What am I missing here?