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]; } }); }
添加回答
举报
0/150
提交
取消