I wrote something quick, hopefully it'll help. Every time start is hit the timer resets
@interface ViewController ()
{
NSTimer *timer;
NSInteger seconds;
}
@end
- (IBAction)start:(id)sender
{
seconds = 5;
[timer invalidate];
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(execute) userInfo:nil repeats:YES];
}
- (void)execute
{
if(seconds > 0) {
NSLog(@"seconds: %li", (long)seconds);
seconds--;
}
else {
NSLog(@"fire");
[timer invalidate];
}
}