Question

Playing around with Timers, and trying to make them behave right when app is sent to background, killed etc.

Judging by the generated comments in xcode, you should disable/invalidate timers on resignActive/enterBackground events.

However, i havent done that yet, but checked what happens to my timer when i click the home button and then re-enter the app.

I basically have a method in my view that the timer triggers every second:

NSLog(@"workedTimTimerTick workedTime; %@", timeString);

And when i exit the app, the output stops, when i re-enter the app, the output starts again...

Since i'm not doing anything code-wise to the timer on those lifecycle events, how come it stops getting called?

Input appreciated!

Was it helpful?

Solution

Your app is suspended when it enters background mode (Application States and Transitions).

Your timer won't fire when the app is in background and the time spent in background isn't taken into account for the timer delay.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top