NStimer value Reset problem
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.
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...
精彩评论