以下代码工作正常:
NSURL* urlAddressJSonUrl = [NSURL URLWithString:urlString];
dispatch_async(globalQueue,
^{
NSData *imageData = [NSData dataWithContentsOfURL:urlAddressJSonUrl];
[self performSelectorOnMainThread:@selector(setImage:)
withObject:[UIImage imageWithData:imageData] waitUntilDone:NO];
});
因为我需要从不同的 viewController 调用它,所以我想将它放在具有公共全局帮助功能 (+) 的通用类中,所以我正在寻找一种方法将选择器和目标作为参数传递给 performSelectorOnMainThread 以运行