I have a timer app which uses a NSTimer to track minutes. How can I keep the timer going, even when the device is put into sleep mode? Thanks!
Scheduled NSTimer instances will halt during sleep. Your application needs to respond to the NSWorkspace's wake notification and adjust its timers.
If you do not respond to wake notifications, your timers will resume but without accounting for the time spent asleep.
See Apple's technical note QA1340 Registering and unregistering for sleep and wake notifications for getting the appropriate notifications.
Consider this situation:
From the timer's perspective, five minutes has passed by. Note the language used by NSTimer, it uses relative durations rather than absolute times, scheduledTimerWithTimeInterval:invocation:repeats:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With