【发布时间】:2014-12-09 10:47:38
【问题描述】:
NSURL 异步请求会冻结,直到上一个 api 调用完成。 我们的项目需要将视频上传到服务器,我们正在使用 GCD 执行此操作。但是,UI 不应该在上传完成之前被冻结。因此,也可以调用其他一些 API。但是,在调用其他 api 时,这些新的 api 调用正在等待视频上传 api 调用完成,以便在队列中完成。
申请流程如下:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//api call for video upload is an NSMutableUrlRequest with Asynchronous completion handler.
dispatch_async(dispatch_get_main_queue(), ^{
//UI operations
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//simple api call for getting minimal data/ validation --- (Problem - This api is getting freeze until the video upload to complete).
});
});
});
【问题讨论】:
标签: ios objective-c-blocks grand-central-dispatch nsoperationqueue nsmutableurlrequest