我可以获取在设备上创建的相册列表PHFetchResult *results = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
我想必须有一种类似的方式来获取共享照片流相册(或者我认为它们现在可能被称为“iCloud 照片共享相册”),但对于我的生活......无法弄清楚。有没有人解决过这个问题?
PhotoKit 的查询逻辑让我很困惑,但下面的答案对我有用(提示:你必须查询 a PHAssetCollection
,而不是 a PHCollectionList
)
PHFetchResult *results = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumCloudShared options:nil]
对于那些寻找快速语法的人:
let result = PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.albumCloudShared, options: nil)
result.enumerateObjects { (phassetcollection, index, setThisToTrueToStop) in
print("\(index): \(phassetcollection.localizedTitle) \(phassetcollection.localIdentifier)")
}