performSelectorOnMainThread:<#(nonnull SEL)#> withObject:<#(nullable id)#> waitUntilDone:<#(BOOL)#> 前两个参数不解释,最后一个waitUntilDone我看网上很多朋友都在问,解释一下。
在子线程里有如下代码:
NSLog(@"before");
[self performSelectorOnMainThread:@selector(callBack:) withObject:image waitUntilDone:NO];
NSLog(@"after");
- (void)callBack:(UIImage *)image
{
NSLog(@"callBack");
imageView.image = image;
}
如果waitUntilDone:YES即需要等待callBack执行完成后,子线程才会继续执行后面的代码