Follow by Email

Search This Blog

Tuesday, 18 March 2014

iOS Timer Counter !!


Here is the Timer counter simple example in which we will get seconds, minutes, and hours

Call the below method TimerCounter:

int secondsSpent;
NSTimer *timer= [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(TimeCounter) userInfo:nil repeats:YES];

- (void)TimeCounter
{
    secondsSpent ++ ;
    hours = secondsSpent / 3600;
    minutes = (secondsSpent % 3600) / 60;
    seconds = (secondsSpent %3600) % 60;
    NSLog(@"Time spent: %02d:%02d:%02d", hours, minutes, seconds);

}

No comments:

Post a Comment