美文网首页
队列数组,并行执行2

队列数组,并行执行2

作者: seventhboy | 来源:发表于2016-11-30 19:03 被阅读8次

    我这里刚写的处理方式
    //1.创建队列组
    dispatch_group_t group = dispatch_group_create();
    //2.创建队列
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    //3.添加请求
    dispatch_group_async(group, queue, ^{
    dispatch_group_enter(group);
    [HomeRequest getPointBuyAllConfigurationStrategyType:_dataType success:^(NSInteger code, NSDictionary *dict) {
    // _buyingStrategyModel.deposit = [dict objectForKey:@"data"];
    dispatch_group_leave(group);
    } failuer:^(NSInteger code, NSString *message) {
    dispatch_group_leave(group);
    }];
    });
    dispatch_group_async(group, queue, ^{
    dispatch_group_enter(group);
    [HomeRequest getStockLeverRiskStockCode:_buyingStrategyModel.stockCode strategyType:_dataType success:^(NSInteger code, NSDictionary *dict) {
    _buyingStrategyModel.leverrisk = [[[dict objectForKey:@"data"] objectForKey:@"level"] floatValue];
    dispatch_group_leave(group);
    } failuer:^(NSInteger code, NSString *message) {
    dispatch_group_leave(group);
    }];
    });
    //4.队列组所有请求完成回调刷新UI
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    NSLog(@"model:%f",_buyingStrategyModel.leverrisk);
    });

    相关文章

      网友评论

          本文标题:队列数组,并行执行2

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