我想使用 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;
}