CGD用法

作者: 杰米 | 来源:发表于2016-09-24 01:44 被阅读19次

多任务

dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, queue, ^{ /*加载图片1 */ });
dispatch_group_async(group, queue, ^{ /*加载图片2 */ });
dispatch_group_async(group, queue, ^{ /*加载图片3 */ }); 
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        // 合并图片
});
 let group = dispatch_group_create()
 dispatch_group_enter(group)
httprequest1(handle:{
//网络1请求成功
dispatch_group_leave(group)
})

 dispatch_group_enter(group)
httprequest2(handle:{
//网络2请求成功
dispatch_group_leave(group)
})
 
  dispatch_group_notify(group, dispatch_get_main_queue(), {
//网络请求完毕
}

相关文章

网友评论

      本文标题:CGD用法

      本文链接:https://www.haomeiwen.com/subject/mccxyttx.html