0

2 つのタイマーを使用して一連のアクティビティ (A と B) を作成したいと思います。タイマーの無効化で問題が発生します... これは正しい方法ですか? ありがとうございました!!!

timerAStart = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startActivityA) userInfo:nil repeats:NO];
timerAStop = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(StopA) userInfo:nil repeats:NO];
timerBStart = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(startActivityB) userInfo:nil repeats:NO];
timerBStop = [NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(StopB) userInfo:nil repeats:NO];
- (void) StopA {
[timerAStart invalidate];
timerAStart=nil;
}
- (void) StopB {
[timerBStart invalidate];
timerBStart=nil;
}
4

1 に答える 1

1

タイマーは繰り返さないため、無効にする必要はありません。ドキュメントを見ると、繰り返さないタイマーが自己無効化することがわかります。

于 2012-06-21T21:22:47.183 に答える