使用ALAssetsLibrary从iphone相册中读取图片需要30秒才能加载700张图像。是否还有其他版本的代码使用ALAssetsLibrary?我的代码版本低于
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
NSLog(@"number of assets = %ld",(long)group.numberOfAssets);
[group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
if(result == nil) {
return;
}
ALAssetRepresentation *representation = [result defaultRepresentation];
BR_AssetsInfo *info = [[BR_AssetsInfo alloc] init];
info.thumbnail = [UIImage imageWithCGImage:[result thumbnail]];
info.originalImage = [UIImage imageWithCGImage:[representation fullResolutionImage]];
info.imageURLString = [[representation url] absoluteString];
info.isSelected = NO;
for (BR_AssetsInfo *asset in self.selectedAssetsArray) {
if ([asset isEqual:info]) {
info.isSelected = YES;
}
}
[self.assetsDataArray addObject:info];
[self.photosCollectionView reloadData];
}];
} failureBlock:^(NSError *error) {
if (error.code == ALAssetsLibraryAccessUserDeniedError) {
NSLog(@"user denied access, code: %li",(long)error.code);
}else{
NSLog(@"Other error code: %li",(long)error.code);
}
}];