gpt4 book ai didi

iphone - sleep 功能的替代方案

转载 作者:行者123 更新时间:2023-12-03 18:31:03 27 4
gpt4 key购买 nike

我在我的应用程序中实现了以下内容。

for(i=0;!stopThroughButtons && i<totalMovements;i++){
[NSThread detachNewThreadSelector:@selector(moveNeedle) toTarget:self withObject:nil];
sleep(0.3);
}

这里的sleep是一个参数为unsigned int类型的函数。

Sleep 方法使用秒数来休眠。

我想以毫秒为单位给出 sleep 时间。

有哪些最佳替代方案可用?

最佳答案

还有 NSThread 的 +sleepForTimeInterval:,它需要以秒为单位的时间。例如:

[NSThread sleepForTimeInterval:0.05];

应该休眠 50 毫秒。

关于iphone - sleep 功能的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1467894/

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