开发者

NStimer value Reset problem

开发者 https://www.devze.com 2023-03-12 03:04 出处:网络
In My application I m starting one Nstimer when we log in.( loginViewController.m) In my logout page( LogoutViewController.m) i want to stop the NSTimer.

In My application

  1. I m starting one Nstimer when we log in.( loginViewController.m)

  2. In my logout page( LogoutViewController.m) i want to stop the NSTimer.

    I h开发者_Go百科ave Creaated one Function ( loginViewController.m)

     -(void)InvalidateTimer
     {
        if ([self.timerDownload isValid]) 
        {
            [timerDownload invalidate];
            timerDownload = nil;
        }
      }
    

    And Call From LogoutViewController.m

    LoginViewController *login =[[LoginViewController alloc]init];
    
    [login InvalidateTimer];
    

    when we click Logout button.

    But self.timerDownload value is Coming 0X0 and not Inavlidate NSTimer. Please help

Thanks in advance


You are creating new instance of login view controller and invalidating its timer. Ofcourse this new instance is not same as the old instance of login view controller where you started your timer.


you have to make it as global in appdelegate or you have to send object of loginview to logout view and make it to work...

0

精彩评论

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