我遍历 iOS 设备上的相册列表。在遍历这个组之后,我想简单地打印出找到的专辑数量。
我必须在我的代码中更改该NSLog
语句仅在加载所有专辑时才执行的内容。
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
void (^groupBlock)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop){
if (group == nil){return;}
[tempArray addObject:group];
};
void (^failureBlock)(NSError *) = ^(NSError *error) {
NSLog(@"A problem occured %@", [error description]);
};
[library enumerateGroupsWithTypes:ALAssetsGroupAll
usingBlock:groupBlock
failureBlock:failureBlock];
NSLog(@"%i albums were loaded", tempArray.count);