1.GCD 延迟两秒
dispatch_time_t sleepTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC));
dispatch_after(sleepTime, dispatch_get_main_queue(),^{
//延迟执行相关代码
});
2.performSelector 延迟两秒
[self performSelector:@selector(sleepTime) withObject:nil afterDelay:2.0];
3.定时器
[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(sleepTime) userInfo:nil repeats:NO];
repeats: 重复
网友评论