The Code
if ( !_groups) {
_groups = [[NSMutableArray alloc] init];
} else {
[_groups removeAllObjects];
}
if (!_assetsLibrary) {
_assetsLibrary = [[ALAssetsLibrary alloc] init];
}
ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {
if ( group ) {
DLog(@"group: %@", group);
[_groups addObject:group];
[self.tableView reloadData];
}
};
ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error){
DLog(@"error: %@", error);
};
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupEvent | ALAssetsGroupFaces;
[_assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock];
So the code is straight from WWDC 2010 demo. Session 421.
The Problem
listGroupBlock DLog is never called. And my _groups array is empty;
Technically this block is called 1 time but group parameter is nil.
P.S.
DLog is just pretty NSLog with class name and line in it.
The problem was that on the devices on which I tested, iPad 1, there wasn’t albums/events or faces.
So i’ve changed the groupType from
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupEvent | ALAssetsGroupFaces;to
NSUInteger groupTypes = ALAssetsGroupLibrary | ALAssetsGroupSavedPhotos | ALAssetsGroupAlbum | ALAssetsGroupEvent | ALAssetsGroupFaces;