How to stop/invalidate a NSTimer [duplicate]
开发者_Python百科Possible Duplicate:
NSTimer doesn't stop
How can I stop / invalidate a NSTimer??
Below is the code:
- (void)autoscrollTimerFired:(NSTimer*)timer {
NSLog(@"Each & Every Time this MEthods is called Even if I try to invalidate it in viewDidDisappear ");
}
- (void)viewWillAppear:(BOOL)animated{
if (autoscrollTimer == nil) {
autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(35.0/1000.0)
target:self
selector:@selector(autoscrollTimerFired:)
userInfo:nil
repeats:YES]; // To repeat this thread it's as per my requirement
}
}
-(void) viewWillDisappear:(BOOL)animated {
[autoscrollTimer invalidate];
}
So,please suggest me to do this ...
I had the same problem. I guess you have made it as property nonatomic, retain?
Please do this:
[self.autoscrollTimer invalidate];
Thanks.
精彩评论