Search code examples
iphonenstimerappdelegate

run timer function in background in iPhone


I want to create a function on which I start a count down timer. when time is start than suddenly I close this app then this count down timer running in background. now when I start this app again than time will start proper timing

now just think I start this function the time is remaining time is 4:05:38 . At this time I stop this app , and just start this after 2 minutes than time will b remain 4:03:38.

How can I accomplish this?


Solution

  • Save the countdown time and the actual timeinterval when you close the app.

    Use timeinterval to check how much time is gone in the next start and substract this time from the saved countdown time. Then start your timer again.