需求 : 获取相册信息后获取第一张图片并为self.editImageView
赋值显示.
问题 : 但是我现在想在getImageForCollectionView
完全结束后来为self.editImageView
赋值,那么问题来了,我如何才能判断getImageForCollectionView
函数已经进行完毕?
- (void)getImageForCollectionView{
_library = [[ALAssetsLibrary alloc] init];
self.photos = [NSMutableDictionary dictionary];
[_library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group) {
NSMutableArray *array = [NSMutableArray array];
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if (result) {
[array addObject:result];
}
}];
[self.photos setValue:array forKey:[group valueForProperty:@"ALAssetsGroupPropertyName"]];
}
} failureBlock:^(NSError *error) {
}];
}
将耗时的操作放在非主线程中,需要UI更新的放在主线程中。
EDIT: