```//延时方法1
[self performSelector:@selector(task) withObject:nil afterDelay:1];
//延时方法2
NSTimer *timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(task1) userInfo:nil repeats:false];
//延时方法4
[NSThread sleepForTimeInterval:1.0];
//延时方法4
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1.0), dispatch_get_main_queue(), ^{
NSLog(@"延时方法4");
});
OC中四种延时方法
最新推荐文章于 2023-07-18 15:02:45 发布
本文深入探讨了在iOS开发中使用多种延时方法的原理与实践,包括使用`self.perform`、`NSTimer`、`NSThread.sleep`和`dispatch_after`实现不同场景下的延迟操作。详细解释了每种方法的特性、用法及注意事项,同时提供了实例代码帮助开发者快速上手。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率
2150

被折叠的 条评论
为什么被折叠?



