Reputation: 311
For the sake of learning i'm making a timer. Used an NSTimer but it appears this stops when going to the background. Thought of using NSDate instead. Does this work in the background? Do i compare current time to a set time to get the timer running properly? Some thoughts would be greatly appreciated!
Upvotes: 1
Views: 434
Reputation: 14427
If you are looking for something to handle time based events in the background, have a look at UILocalNotification
. With a local notification, the OS will alert the user at the appointed time whether the app that scheduled the notification is running or not.
If you are looking for something to happen when the app starts, you can use NSUserDefaults
and store a value containing the current timestamp. Fire this off when in the AppDelegate inside applicationWillResignActive
method. You can then check this value in the applicationDidBecomeActive
.
Upvotes: 1