// 创建信号量
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
// 创建全局并行
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, ^{ // 请求一
[loginCode getUserInfoWithNick:nil andUserId:kUserId onSuc:^(id data) {
NSLog(@"yue");
dispatch_semaphore_signal(semaphore); } andFail:^(NSError *error) {
}]; });
dispatch_group_async(group, queue, ^{ // 请求二
[CommodityViewModel getPriceTransformForIntegral:nil onSuccess:^(id data) { NSLog(@"duihuan11");
dispatch_semaphore_signal(semaphore); } onFailure:^(NSError *error) {
}];
});
dispatch_group_async(group, queue, ^{ // 请求三
[CommodityViewModel getPriceTransformForIntegral:nil onSuccess:^(id data) {
NSLog(@"duihuan22");
dispatch_semaphore_signal(semaphore); } onFailure:^(NSError *error) {
}];
}); dispatch_group_notify(group, queue, ^{ // 三个请求对应三次信号等待
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); //在这里 进行请求后的方法,回到主线程
dispatch_async(dispatch_get_main_queue(), ^{ //更新UI操作 }); });

最新文章

  1. VS2012中丢失ArcGIS模板的解决方法
  2. 快速定位性能瓶颈,检查出所有资源(CPU、内存、磁盘IO等)的利用率(utilization)、饱和度(saturation)和错误(error)度量,即USE方法
  3. 达梦7的试用 与SQLSERVER的简单技术对比
  4. query语句的拼接.
  5. HTML-学习笔记(1)
  6. mybaits入门
  7. git 创建版本库
  8. JavaWeb学习计划
  9. dell 交换机 双链路冗余
  10. 【转】android资源目录---assets与res/raw区别
  11. 你的Jsp页面有黄×么,有黄色问号么?Multiple annotations found at this line: - Invalid location of tag (form). - No
  12. Android创建和使用数据库详细指南(1)
  13. B-JUI(Best jQuery UI) 前端框架
  14. 模板类的约束模板友元函数:template friend functions
  15. 利用ASCII码生成指定规则的字符串
  16. [Codeforces]852I - Dating
  17. JSON AST 生成MD
  18. Android APP性能测试笔记(二)
  19. HTTP Client使用总结
  20. Jmeter常用脚本开发之SOAP/XML-RPC Request

热门文章

  1. document.documentElement 和 document.body
  2. 怎样提高js的编程能力
  3. PTA --- Basic Level 1009 说反话
  4. Python爬虫学习==>第二章:MongoDB环境配置
  5. markdown-博客编辑
  6. react中component存在性能问题
  7. 华为HCNA乱学Round 9:VRRP
  8. 【Linux开发】linux设备驱动归纳总结(五):4.写个简单的LED驱动
  9. Flash-aware Page Replacement Algorithm
  10. 【CSP模拟】小凯的疑惑(DP)