I wouldn't use NSTimer. I'd create a NSDate "startDate" ivar in the app delegate and in didBecomeActive, set it to the current date. Then in willResignActive, find the difference between the start date and the current date using timeIntervalSinceDate. Then, check whether a time interval has already been stored in NSUserDefaults, if no just save it to NSUserDefaults. If yes, get the stored time interval and add it. Then save it.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at www.globaclock.com.
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
|