开发者

How to stop/invalidate a NSTimer [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

NSTimer doesn't stop

开发者_Python百科

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜