How can I invalidate the timer when timer going in Background?

Declare your NSTimer variable in AppDelegate method and synthesize it. Then using sharedApplication of AppDelegate, use that variable in whole project and do not create any new variable. Also perform invalidate method on the same instance variable.

There is no need to move your timer to your delegate, in fact that is quite a bad idea as it has no purpose being there! You should observe the following notifications (depending on OS version, the latter being in OS4+)... UIApplicationWillResignActiveNotification UIApplicationDidEnterBackgroundNotification Observe these from within your view controller and invalidate the timer. There are corresponding notifications when the app starts again... UIApplicationDidBecomeActiveNotification UIApplicationWillEnterForegroundNotification.

Thanks for answer, can you give me a some sample or more detail.. – Ankit yesterday.

In one global file create a time. In app delegate method, (void)applicationDidEnterBackground:(UIApplication *)application { NSTimer *t ; if (t isValid) { t invalidate; } } use above code shall help you to stop timer when application goes into background.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions