GCDAsyncSocket异步串行子线程中for发送图片

GCDAsyncsocket 使用异步串行子线程中for循环执行一半就不执行了,代码如下,过程是点击发送按钮返回到主页面,然后异步执行下面的代码上传图片;
   dispatch_queue_t queue = dispatch_queue_create("uploadImage", DISPATCH_QUEUE_SERIAL);
           for (int i =0; i < 10; i++) {
               dispatch_async(queue, ^{
                  
             NSLog(@"async ------------ %@", [NSThread currentThread]);
            
            //第一张图的资源
            PHAsset *asset = self.sendImageArray[i];
            NSString *fileType;
            NSString *fileName;
          
            if (asset.mediaType == PHAssetMediaTypeImage) {
                fileType = @"jpg";
                NSData *data = [NSData dataWithContentsOfFile:filePath[i]];

                [self upLoadImageData:data type:@"jpg" name:fileName];
            } else if(asset.mediaType == PHAssetMediaTypeVideo) {
                fileType = @"mp4";
                  NSData *data = [NSData dataWithContentsOfFile:filePath[i]];
                [self uploadMp4Data:data type:fileType name:fileName];
                
            }
            
          });
      }

        

慕粉1436207659
浏览 1312回答 1
1回答

谢凌

这个不算异常
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

iOS