-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event{
//调用time延迟调用的方法 [self time];}-(void)time{
//after在...之后调度,在这里我们只需要填写时间(2.0 * NSEC_PER_SEC)及延迟2.0秒后需要进行的操作 NSLog
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"%@",[NSThread currentThread]);
});
NSLog(@"%@",[NSThread currentThread]);}
打印效果如下
2016-07-03 15:41:27.789 GCD使用[4210:302966]{number = 1, name = main}
2016-07-03 15:41:29.984 GCD使用[4210:302966]{number = 1, name = main}