我试图仅从 PHAssetCollection 获取图像,但我没有看到谓词影响结果。我正在将 PHFetchOptions 设置为 mediaType == Image 但是当我从库中选择一个视频时,它会传递谓词并且 println 也会确认该类型。
不知道为什么会这样,我可能在这里遗漏的任何问题?
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "mediaType == %d", argumentArray: [PHAssetMediaType.Image.rawValue])
println(fetchOptions) // mediaType == 1
let assetsFetch = PHAsset.fetchAssetsInAssetCollection(assetCollection, options: fetchOptions)
assetsFetch.enumerateObjectsUsingBlock { (obj:AnyObject!, idx:Int, stop:UnsafeMutablePointer<ObjCBool>) -> Void in
if let asset = obj as? PHAsset{
println(asset)
//prints: <PHAsset: 0x1703a1f80> A45796D5-528F-4D5E-A8D8-5F3F47CF40A1/L0/001 mediaType=2/0, assetSource=3, (1920x1080), creationDate=2014-11-11 16:34:12 +0000, location=1, hidden=0, favorite=0
}
}