Continuous Timeline in Iphone App?
Background: Workout App is designed to have a continuous timeline that I can then input what exercise and reps I'm doing in开发者_JS百科 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?
You could try CACurrentMediaTime which returns mach_absolute_time in seconds. This should be accurate across sleep.
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
精彩评论