-1

I am new in ios application development. I want to set countdown timer of 30 min in my application so I had put this code in my application it is working but in below code it will continue start from 30 minutes again and again and again. I want to exit that exam page on completing 30 minutes so how can I do this can any one help me please .

thank you

CountDown Timer ios tutorial?

Community
  • 1
  • 1

2 Answers2

0

Remove this secondsLeft = 16925; from updateCounter.

- (void)updateCounter:(NSTimer *)theTimer {
    if(secondsLeft > 0 ){
        secondsLeft -- ;
        hours = secondsLeft / 3600;
        minutes = (secondsLeft % 3600) / 60;
        seconds = (secondsLeft %3600) % 60;
        myCounterLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds];
    }
    else{
        if(timer != nil)
        {
            [timer invalidate];
            timer = nil;
        }
        //Write the code to exit your exam page
    }
}

Hope this helps.. :)

Rashad
  • 11,057
  • 4
  • 45
  • 73
0

I think you does not need to add Timer for this task.

You can simple call your method like :

[self performSelector:@selector(yourMethod) withObject:nil afterDelay:1800];

Now it will call your method after 30 minutes or say 1800 seconds.

Sandeep Singh
  • 268
  • 1
  • 9