3

I am doing the iOS timer application, but when I press the home button the timer will stop.

I would like to know if close the application, the program can keep working?

And go back the application can keep running.

I see some article How to write a background service in iphone application? said can't run in background.

Can some one help me?

Thank you.

Community
  • 1
  • 1
user1068895_CHU
  • 251
  • 1
  • 4
  • 11

1 Answers1

3

If it's a timer you are doing, you can always keep the time when it started, through CACurrentMediaTime(), and if your application goes in the background, when it comes to the foreground again, in applicationDidBecomeActive:(UIApplication *)application, take another CACurrentMediaTime() poll, and display the difference between the numbers.

I believe this is how the Apple's bundled app works. No need to keep processing that number if the application is not used.