在商城APP中,有些时候需要先处理图片上传。商品APP中,某个订单的立即评价,存在多个商品,一起评价。先将这多张图上传到服务器并返回图片对应的url,然后再把这些图片url和文字作为动态的属性发布到服务器。
dispatch_group_t group = dispatch_group_create();
dispatch_async(dispatch_get_global_queue(0, 0), ^{
for (goodsOrderModel *goodsOrder in self.model.list) {
if (goodsOrder.selectedPhotos.count>0) {
dispatch_group_enter(group);
[self UploadPhotoFile:goodsOrder.selectedPhotos block:^(BOOL isTrue) {
if (isTrue) {
NSLog(@"上传出错");
dispatch_group_leave(group);
}else{
NSLog(@"上传成功");
dispatch_group_leave(group);
}
}];
}
}
dispatch_group_notify(group, dispatch_get_global_queue(0, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"其他操作,提交评论");
});
});
});