There is a UIVew with a start button, a UILabel in which the current time is recorded and a uitableView in which the time is saved (as a simple standard timer)
The problem is that when scrolling the table - the timer freezes, how to make them work synchronously?
I have such a timer
- (IBAction)startTimer { _startButton.hidden = YES; _stopButton.hidden = NO; isRun = YES; UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid; UIApplication *app = [UIApplication sharedApplication]; bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgTask]; }]; myTimer = [NSTimer scheduledTimerWithTimeInterval:0.01f target:self selector:@selector(tick) userInfo:nil repeats:YES]; }
and funky
- (void)tick { _timeSot++; sot++; if (_timeSot > 99) { _timeSot = 0; _sec++; } if (_sec > 59) { _sec = 0; _min++; } //_min = _sec / 60; NSString *sotStr; if (_timeSot < 10) { sotStr = [NSString stringWithFormat:@"0%d", _timeSot]; } else { sotStr = [NSString stringWithFormat:@"%d", _timeSot]; } NSString *secStr; if (_sec < 10) { secStr = [NSString stringWithFormat:@"0%d", _sec]; } else { secStr = [NSString stringWithFormat:@"%d", _sec]; } NSString *minStr; if (_min < 10) { minStr = [NSString stringWithFormat:@"0%d", _min]; } else { minStr = [NSString stringWithFormat:@"%d", _min]; } myTime = [NSString stringWithFormat:@"%@:%@:%@", minStr, secStr, sotStr]; if (sot >= ([[[_exerises objectAtIndex:_indexExercise] objectForKey:@"timeWorkOutExerciseClient"] intValue] * 100)) { [self stopTimer]; [self sendNotification]; } [_timeLabel setText:myTime]; }