dispatch_queue_t callerQueue = dispatch_get_current_queue();
dispatch_retain(callerQueue);
dispatch_queue_t downloadQueue = dispatch_queue_create("Download Queue",NULL);
dispatch_async(downloadQueue,
^{
//some code that accesses a web service
dispatch_async(callerQueue,
^{
//some code that accesses UI
});
});
dispatch_release(downloadQueue);
NSLog(@"great successing!");
问题是,“大获成功!”从来没有出现过,并且在代码最外面的块的末尾没有发生任何事情。我不确定我做错了什么,但我知道这有些严重错误。dispatch_async自定义队列永远不会退出块
试过了你的代码,它正在工作:http://pastie.org/2944762 –
确实如此是......所以它必须与提前发布的下载队列有关,我想下载需要一段时间。 –