为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

iOS
慕粉1436207659 2016-12-05 14:39:11
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];                            }                       });      }        
查看完整描述

1 回答

?
谢凌

TA贡献41条经验 获得超14个赞

这个不算异常

查看完整回答
反对 回复 2016-12-05
  • 1 回答
  • 1 关注
  • 1311 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信