不确定这是否是这个问题的正确标题..无论如何, 我有一个字典数组,我正在迭代字典,传入一个块,有时在将来执行(异步)并将结果保存在字典中。这是我的方法:
- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info {
NSLog(@"%@", info);
NSMutableDictionary *images = [NSMutableDictionary dictionaryWithCapacity:[info count]];
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
for (NSDictionary *dict in info) {
NSURL *assetURL = [dict objectForKey:UIImagePickerControllerReferenceURL];
[library assetForURL:assetURL
resultBlock:^(ALAsset *asset) {
NSString *filename = asset.defaultRepresentation.filename;
UIImage *image = [dict objectForKey:UIImagePickerControllerOriginalImage];
[images setObject:filename forKey:image];
}
failureBlock:^(NSError *error) {
[SVProgressHUD dismissWithError:@"Error occured."];
}
];
}
NSLog(@"%@", images);
[library autorelease];
[self dismissImagePickerVC];
}
当然,在这个方法结束时,图像是空的,但我的问题是,当每次迭代的所有块都被执行时,如何才能回调? Thansk
答案 0 :(得分:0)