Hello all,
I have developed an application in which I'm running a countdown timer. The timer fires a method every second. However, when the phone is in sleep mode, the timer becomes slow or even turns off.
I think I need to update the variables by calculating the time intervals using NSDate. Does someone knows how to do this?
BTW, our client has sent the following feedback:
The timer problem appears to be caused by the fact that the code assumes that the timer notification messages are delivered at exactly one second, but aren't. When the app is running but the phone is in standby, it uses the timer to update the countdown timer. But the timer comes in way more slowly than one second, so the countdown timer is off. The app should be reworked to always update the countdown timer based on the current time, and not count down based on the timer messages themselves. (In other words, when the one second message comes in, always assume that additional time has gone by and calculate the remaining time by subtracting from the target time. This is what happens when you restart the app -- it figures out the target time and the current time, subtracts one from the other, and updates the onscreen timer. Well, this is how it should always do it.)
If someone understand what exactly we need, please tell me.