240 发简信
IP属地:贵州
  • @归虹尘 看文章内容中的 getA 这个方法

    iOS GCD之多个请求顺序执行

    一、业务场景。 各个方法都是异步,但需要他们顺序执行。如提交信息C(submitC)之前需要获取B(getB),而获取B(getB),则需要先获取A(getA)。getA--...

  • 给所有上传任务增加信号量来判断是否所有任务都已完成。代码如下:
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)),
    dispatch_get_main_queue(), ^{
    dispatch_group_t group = dispatch_group_create();
    for (NSInteger index = 0; index < imageDataArray.count; index++) {
    dispatch_group_enter(group);
    [[LDHttpRequest sharedLDHttpRequest] uploadImage:requestUrl imageData:imageDataArray[index] params:nil parameterOfImage:@"file" success:^(id responseObj) {
    if ([responseObj objectForKey:@"url"]) {
    NSDictionary *dic = @{
    @"fileName":[responseObj objectForKey:@"submittedFileName"],
    @"filePath":[responseObj objectForKey:@"url"]
    };
    @synchronized (result) { //同步锁
    result[index] = dic;
    }
    }
    dispatch_group_leave(group);
    } fail:^(LocalError *localError, NSError *netError) {
    dispatch_group_leave(group);
    }];
    }
    NSMutableArray *fileList = [NSMutableArray array];
    //所有任务都完成
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
    for (NSDictionary *dic in result) {
    if([dic objectForKey:@"filePath"]){
    [fileList addObject:dic];
    }
    }
    weakSelf.fileList = fileList;
    [self submitAll:loading];
    });

    });

    iOS GCD之多个请求顺序执行

    一、业务场景。 各个方法都是异步,但需要他们顺序执行。如提交信息C(submitC)之前需要获取B(getB),而获取B(getB),则需要先获取A(getA)。getA--...

  • 120
    今年我读了四个开源项目的源码,来分享下心得

    Hola,我是 yes。 今年来看了 RocketMQ、Kafka、Dubbo 、Tomcat 的源码,之前也有读者询问过如何读源码,索性就来分享一下。 其实还看了一点点 L...

  • 120
    iOS12、iOS11、iOS10、iOS9常见适配

    一、iOS12(Xcode10) 1.1、升级Xcode10后项目报错 不允许多个info.plist Xcode10是默认选中的最新的New Build System(De...

  • iOS GCD之多个请求顺序执行

    一、业务场景。 各个方法都是异步,但需要他们顺序执行。如提交信息C(submitC)之前需要获取B(getB),而获取B(getB),则需要先获取A(getA)。getA--...

个人介绍
夫唯不盈,故能敝而新成