延时操作

 

1.NSObject方法performSelector:withObject:afterDelay:

[self performSelector:@selector(run) withObject:nil afterDelay:2.0];

 

2.NSTimer方法

[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(run) userInfo:nil repeats:NO];

 

3.GCD

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            NSLog(@"run-----");
        });

 

posted on 2016-03-21 11:02  sea_star3  阅读(272)  评论(0编辑  收藏  举报

导航