首页 > 代码库 > 队列组用于多个网络请求
队列组用于多个网络请求
dispatch_group_t group = dispatch_group_create(); dispatch_queue_t serialQueue = dispatch_queue_create("com.wzb.test.www", DISPATCH_QUEUE_SERIAL); dispatch_group_enter(group); dispatch_group_async(group, serialQueue, ^{ // 网络请求一 [WebClick getDataSuccess:^(ResponseModel *model) { dispatch_group_leave(group); } failure:^(NSString *err) { dispatch_group_leave(group); }]; }); dispatch_group_enter(group); dispatch_group_async(group, serialQueue, ^{ // 网络请求二 [WebClick getDataSuccess:getBigTypeRM onSuccess:^(ResponseModel *model) { dispatch_group_leave(group); } failure:^(NSString *errorString) { dispatch_group_leave(group); }]; }); dispatch_group_enter(group); dispatch_group_async(group, serialQueue, ^{ // 网络请求三 [WebClick getDataSuccess:^{ dispatch_group_leave(group); } failure:^(NSString *errorString) { dispatch_group_leave(group); }]; }); // 所有网络请求结束后会来到这个方法 dispatch_group_notify(group, serialQueue, ^{ dispatch_async(dispatch_get_global_queue(0, 0), ^{ dispatch_async(dispatch_get_main_queue(), ^{ // 刷新UI }); }); });
队列组用于多个网络请求
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。