ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if(group != nil){
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result != nil){
//获取资源的类型
NSString *type = [result valueForProperty:ALAssetPropertyType];
if([type isEqualToString:ALAssetTypePhoto]){//照片
//获取缩略图
CGImageRef thumbCGImage = [result thumbnail];
UIImage *thumImage = [UIImage imageWithCGImage:thumbCGImage];
//获取原图
ALAssetRepresentation *representation = [result defaultRepresentation];
CGImageRef fullCGImage = [representation fullResolutionImage];
UIImage *fullImage = [UIImage imageWithCGImage:fullCGImage];
}else if([type isEqualToString:ALAssetTypeVideo]){//视频
ALAssetRepresentation *representation = [result defaultRepresentation];
NSURL *url = [representation url];
//播放视频
}
}
}];
}
} failureBlock:^(NSError *error) {
NSLog(@"遍历错误");
}];