Commit 93f33a43 authored by yuzheng.tz's avatar yuzheng.tz

通过判断collection.estimatedAssetCount提前过滤空相册

parent e42f24ed
...@@ -136,6 +136,8 @@ static dispatch_once_t onceToken; ...@@ -136,6 +136,8 @@ static dispatch_once_t onceToken;
for (PHAssetCollection *collection in smartAlbums) { for (PHAssetCollection *collection in smartAlbums) {
// 有可能是PHCollectionList类的的对象,过滤掉 // 有可能是PHCollectionList类的的对象,过滤掉
if (![collection isKindOfClass:[PHAssetCollection class]]) continue; if (![collection isKindOfClass:[PHAssetCollection class]]) continue;
// 过滤空相册
if (collection.estimatedAssetCount <= 0) continue;
if ([self isCameraRollAlbum:collection]) { if ([self isCameraRollAlbum:collection]) {
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
model = [self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets]; model = [self modelWithResult:fetchResult name:collection.localizedTitle isCameraRoll:YES needFetchAssets:needFetchAssets];
...@@ -178,6 +180,8 @@ static dispatch_once_t onceToken; ...@@ -178,6 +180,8 @@ static dispatch_once_t onceToken;
for (PHAssetCollection *collection in fetchResult) { for (PHAssetCollection *collection in fetchResult) {
// 有可能是PHCollectionList类的的对象,过滤掉 // 有可能是PHCollectionList类的的对象,过滤掉
if (![collection isKindOfClass:[PHAssetCollection class]]) continue; if (![collection isKindOfClass:[PHAssetCollection class]]) continue;
// 过滤空相册
if (collection.estimatedAssetCount <= 0) continue;
PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option]; PHFetchResult *fetchResult = [PHAsset fetchAssetsInAssetCollection:collection options:option];
if (fetchResult.count < 1) continue; if (fetchResult.count < 1) continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment