延迟
1》perform
3秒后自动回到当前线程调用self的download:方法,并且传递参数:@"http://555.jpg"
// 一旦定制好延迟任务后,不会卡主当前线程,
[self performSelector:@selector(download:) withObject:@"http://555.jpg" afterDelay:3];
2》dispatch_after
// 3秒后自动开始新线程执行block中的代码
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), queue, ^{
NSLog(@"---task---%@", [NSThread currentThread]);
});