views:

37

answers:

2

Background: Workout App is designed to have a continuous timeline that I can then input what exercise and reps I'm doing in real-time, then graph the results in real-time.

Issue: When the iphone sleeps for too long, we lose the continuity of the Timeline and it restarts. We haven't figured out how to keep the timeline updating while the App is sleeping. I've asked him to do a call to the Iphone internal clock and do the math on where the viewer should be and move them to that point on the timeline. However, he can't figure out how to do this.

Solutions: Have you folks heard of anyways to do this call to the internal clock? Perhaps a better question, can you think of another way around the problem in general?

+1  A: 

You could try CACurrentMediaTime which returns mach_absolute_time in seconds. This should be accurate across sleep.

drawnonward
+1  A: 

There is no certain way that can assure you app will be running in the background for ever. (If this is what you need) Even Steve said is Multitasking, iPhone resources are very limited and this means that your app will might be killed while it is in the background without any kind of notification. (Except by the notification you get when entering the background)

The best thing you can do is low your resource usage. (release as many objects as possible) Because when the system needs memory it will start killing apps in the background starting by the app that uses more resources.

If you are implementing streaming protocols then is different.

Hope this helps

nacho4d
Say I close out of the app with the home button. My understanding is that it "freezes" the app. Is there a way to bring it back to life while fast forwarding the timeline?thx Nacho!
scottorn
OS does not freezes it instantaneously. It still alive for a moment or days, it depends(see my explanation above). You will have to write you update method using CACurrentMediaTime or CFAbsoluteTimeGetCurrent and recalculate your stuff.You probably want to write this inside -applicationDidBecomeActive: method from UIApplicationDelegate
nacho4d