を使用してループプロセスを使用する方法を教えてくれる人はいますNSTimer
か? ボタンによってトリガーされる 2 つのプロセス タイマーがあり、timer1 と timer2 が n ループ (timer1 -> timer2 -> timer1 -> timer2 など、n ループまで繰り返される) に繰り返されます。私はxcodeが初めてです。教えて下さい。両方のタイマーにユーザーによる入力があります。可能であれば例を教えてください。
私のコードは次のようになります。私が間違っていたら訂正してください
- (void) timer2Elapsed:(NSTimer *) timer;
{
...
displayCountDown.text = [NSString stringWithFormat:@"%d : %d : %d", hour , minute, second];
}
- (void)timer1Elapsed: (NSTimer *) timer;
{
...
displayCountDown.text = [NSString stringWithFormat:@"%d : %d : %d", hour , minute, second];
}
カウントダウンをトリガーする私のボタン:
- (IBAction)startBtn:(id)sender {
endSetTime = [NSDate timeIntervalSinceReferenceDate] + totalSecondTime;
endSetRest = [NSDate timeIntervalSinceReferenceDate] + totalSecondRest;
countdownTimer = [NSTimer scheduledTimerWithTimeInterval: 0.99 target: self selector: @selector(timer1Elapsed:) userInfo: nil repeats: YES];
}
ここの誰かがこのコードを使用するように私に言いましたが、中に何を書き、どこに置くべきかわかりませんか? 彼はループのために言った?知らない?そして、ボタン内でそのコードを接続する方法は?
+ (void) startTimer:(id)timer
{
static int numberOfTimes = 0;
if(numberOfTimes >= 5)
{
numberOfTimes = 0;
return;
}
numberOfTimes ++;
[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(timer1Elapsed:) userInfo:nil repeats:NO];
}