Requirement: After obtaining the album information, get the first picture and assign a value toself.editImageView
for display.
Problem: But now I want togetImageForCollectionView
after it is completely completed. ##self.editImageViewassignment, then the question is, how can I judge that the
getImageForCollectionViewfunction 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: