문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top