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(@"遍歷錯誤");
}];