gpt4 book ai didi

ios - NSTimer - 事件序列 - 如何使计时器无效?

转载 作者:行者123 更新时间:2023-11-29 04:35:17 25 4
gpt4 key购买 nike

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

最佳答案

您不需要无效,因为您的计时器是不重复的。如果您查看文档,您会发现非重复计时器会自行失效。

关于ios - NSTimer - 事件序列 - 如何使计时器无效?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11146552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com