Requirement: After obtaining the album information, get the first picture and assign a value to self.editImageView
for display.
Problem: But now I want to getImageForCollectionView
after it is completely completed. ##self.editImageView assignment, then the question is, how can I judge that the
getImageForCollectionView function has been completed?
- (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) {
}];
}
Place time-consuming operations in non-main threads, and those that require UI updates in the main thread.
EDIT: