三中常用的延时

来源:互联网 发布:淘宝的购物流程 编辑:程序博客网 时间:2024/04/27 11:04
//延迟执行    //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]);    });
0 0
原创粉丝点击