Question

For my stopWatch project, i want to run the timer, when application goes to background (like "stopwatch" inside iPhone clock). I have tried 'beginBackgrounTaskWithExpirationHandler', but it will only execute the task up to 10 minutes. How can i do this without this limit. can any one help me how to solve this ....

Thanks for your quick reply.. Here is my code:

ViewController.m

- (void)countDown{
    count = count - 1;

    //until 30 minutes i need to play an animation here... 

        if(count == 0)
        {
           //close timer...
        [myTimer invalidate];
        myTimer = nil;

           //update counter again
             [self updateCounter];
        }
}

//update counter function...

- (void)updateCounter{

    //setting count value
    count = 1800;

    //count-down fun
    myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(countDown) userInfo:nil repeats:YES];

}

This is what i am looking to execute even in the background.... help me please..

Was it helpful?

Solution

  1. You can't (extend the background time of your app)
  2. Use a local notification instead.

OTHER TIPS

Actually, if you only need the time, simply adjust your clock when you application becomes active again.

If you need to be active at a certain time, use scheduleAlarmForDate:, see Apple documentation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top