0
我遇到问题。我在dispatch_async
中调用了一些方法。但在callMethod2
不同的对象我上传图像[NSURLConnection sendAsynchronousRequest
。但上传后,它不显示我的回应。 (但是,当我调用callMethod2没有dispatch_async,它很好)。哪里可以解决问题?在dispatch_async中上载UIImage
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
[offline callMethod1];
[offline callMethod2];
});
上传图像
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
NSLog("Never show me me this log");
}];
我想因为你从另一个队列中调用这个方法,并且在你使用异步方法(所以它是从另一个线程调用的)method2的实现中,我建议你从dispach异步中调出方法2。 – Mohamad
'NSURLConnection sendAsynchronousRequest'已经是异步的,移动你的'[offline callMethod1];' &&'[offline callMethod2];'dispatch_async(dispatch_get_global_queue()}];'不要担心它不会阻止主线程。 – 0yeoj