分と秒を表示するために作業しているNSTimerを使用しています。しかし、私は時間を計算するために必要な数学について混乱しています。
使ってます:
- (void)updateCounter:(NSTimer *)theTimer {
static int count = 0;
count += 1;
int seconds = count % 60;
int minutes = (count - seconds) / 60;
// Not sure how to calculate hours
int hours = (count - minutes) / 60;
self.timer.text = [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, seconds];
}
どのような計算を何時間も使用する必要がありますか?