//延迟执行
//1.timer定时器
// NSTimer *timer = [NSTimer timerWithTimeInterval:<#(NSTimeInterval)#> target:<#(nonnull id)#> selector:<#(nonnull SEL)#> userInfo:<#(nullable id)#> repeats:<#(BOOL)#>]
//2.performSelector
// [self performSelector:<#(nonnull SEL)#> withObject:<#(nullable id)#> afterDelay:<#(NSTimeInterval)#>]
//GCD的延迟执行,时间单位是纳秒,精度高
/*
1.指定延迟时间 通过dispatch_time函数生成
2.队列
3.任务
*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"ok %@",[NSThread currentThread]);
});
三中常用的延时
最新推荐文章于 2021-06-21 04:14:35 发布