图片批量上传 -串行异步
2017-04-13 本文已影响0人
Markcf
- (void) uploadMultiplePicturesWith:(NSArray<UIImage *> *) pictures
IndexArr:(NSMutableArray *) indexArr //传空数组 ,用于记录上传成功图片账张数
completion :(void(^)(BOOL isSuccess)) completion{
if (!indexArr) {
indexArr = [NSMutableArray array];
}
if ([indexArr count] >= [pictures count]) {
completion(YES);
return;
}
[self upLoadSigleImage:pictures[indexArr.count] completion:^(BOOL isSuccess) {
if (isSuccess) {
[indexArr addObject:@(1)];
[self uploadMultiplePicturesWith:pictures IndexArr:indexArr completion:completion];
}else{
completion(NO);
return;
}
}];
}