timer1Elapsed がカウントダウン タイマーを終了してから次の timer2Elapsed に進み、カウントダウンが終了したら timer1Elapsed に戻ってカウントダウンする、というように 5 回繰り返します。(A -> B -> A -> B ... 5 回) のように見えます A の状態で、B には固定時間があります。A を 1 分間カウントし、B を 30 秒間カウントするとします。私は初心者なので、タイプミスをしないでください。コードが間違っている場合は修正してください。寛大になってください。
- (void) timer2Elapsed:(id)timer
{
...
if (remainingTime <= 0)
{
[timer invalidate];
[NSTimer scheduledTimerWithTimeInterval:0.99 target:self selector:@selector(timer3Elapsed:) userInfo:nil repeats:YES];
}
myDisplay.text = [NSString stringWithFormat:@"%d : %d : %d", hour , minute, second];
}
- (void) timer1Elapsed:(id)timer
{
...
if (remainingTime <= 0)
{
[timer invalidate];
[NSTimer scheduledTimerWithTimeInterval:0.99 target:self selector:@selector(timer2Elapsed:) userInfo:nil repeats:YES];
}
myDisplay.text = [NSString stringWithFormat:@"%d : %d : %d", hour , minute, second];
}
これは私のボタンです
- (IBAction)startBtn:(id)sender {
[NSTimer scheduledTimerWithTimeInterval:0.99 target:self selector:@selector(timer1Elapsed:) userInfo:nil repeats:YES];
}