I have a NSTimer that already works however want to pause it when you click a button. This button besides pause redirects me to my other view then when I get back to the home view he has to continue where you left off. I already have the pause button and I intend to continue counting calling a method on viewWillAppear
this is my code:
- (void)viewDidLoad {
[super viewDidLoad];
[self setUp];
}
- (void) setUp {
_startDate = [NSDate date];
_timer = [NSTimer scheduledTimerWithTimeInterval: 1.0/100.0 target: self selector: @selector(timerUpdating) userInfo: nil repeats: true];
}
-(void)timerUpdating {
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:_startDate];
NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
NSDateFormatter *dateFormater = [[NSDateFormatter alloc]init];
[dateFormater setDateFormat:@"mm:ss"];
[dateFormater setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
NSString *timeString = [dateFormater stringFromDate:timerDate];
self.timerLabel.text = timeString;
self.pauseTimeInterval = &(timeInterval);
}
- (IBAction)timerActionPause:(id)sender {
}