【发布时间】:2026-01-27 00:45:02
【问题描述】:
这是我的代码:
var galleryController: GalleryController!
var albums: PHFetchResult = PHFetchResult()
var cameraRoll: [PHFetchResult] = [PHFetchResult]()
albums=getAlbums()
cameraRoll=getcameraRoll()
func getAlbums()->PHFetchResult<AnyObject>
{
let fetchOptions=PHFetchOptions()
fetchOptions.predicate=NSPredicate(format:"estimatedAssetCount > 0")
return PHAssetCollection.fetchAssetCollections(with: PHAssetCollectionType.album, subtype: PHAssetCollectionSubtype.albumSyncedAlbum, options: fetchOptions) as! PHFetchResult<AnyObject>
}
func getcameraRoll()->[PHFetchResult<AnyObject>]
{
self.photosFromCameraRoll=PHAsset.fetchAssets(with: PHAssetMediaType.image, options: nil)
return [self.photosFromCameraRoll]
}
对于var albums: PHFetchResult = PHFetchResult() 行,Xcode 遇到此消息:“无法将 PHFetchResult<_> 类型的值转换为指定的 PHFetchResult”
对于 var cameraRoll: [PHFetchResult] = [PHFetchResult]() 行,Xcode 也出现相同的消息:“无法将 PHFetchResult<_> 类型的值转换为指定的 PHFetchResult”
【问题讨论】:
-
您可能想向我们提供一些有关“PHFetchResult”的详细信息?