方法一:
// waitUntilDone:是否线程任务完成执行
[self performSelectorOnMainThread:@selector(updateImage:) withObject:data waitUntilDone:YES];
方法二:
dispatch_async(dispatch_get_main_queue(), ^{
//更新UI的代码,不用主线程中调用
});
方法三:
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSLog(@"线程2:%@",[NSThread currentThread]);
}];
网友评论