【发布时间】:2017-06-28 11:06:35
【问题描述】:
在 iOS PhotoKit 中,我可以像这样获取所有非空相册:
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "estimatedAssetCount > 0")
let albumFetchResult = PHAssetCollection.fetchAssetCollections(with: .album, subtype: .any, options: albumFetchOptions)
albumFetchResult.enumerateObjects({ (collection, _, _) in
// Do something with the album...
})
然后我只能从相册中获取这样的照片:
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetResourceType.photo.rawValue)
let fetchResults = PHAsset.fetchAssets(in: collection, options: fetchOptions)
但是第一部分可以给我只有视频的专辑,这意味着在我将谓词应用于第二部分后,专辑将是空的。在我开始使用它们之前,有没有办法在第一部分中过滤掉这些专辑?
【问题讨论】: