持续检查某件事是否发生以及如果那件事发生了你执行一组命令的最有效方法是什么? (我正在使用 C 和 Obj-C)
最佳答案
使用这个。
NSTimer *newTimer = [NSTimer timerWithTimeInterval:5 target:self selector:@selector(checkBoolValue) userInfo:nil repeats:YES];
此方法将每 5 秒运行一次 checkBoolValue。
现在,当你的 bool 值被设置时,然后停止计时器
[newTimer invalidate];
newTimer = nil;
关于objective-c - 继续检查直到 True,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7090735/