这是我的代码:
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]
}
Run Code Online (Sandbox Code Playgroud)
对于var albums: PHFetchResult = PHFetchResult()Xcode 正在使用此消息的行:“无法将类型的值转换PHFetchResult<_>为指定的 PHFetchResult”
对于行var cameraRoll: [PHFetchResult] = [PHFetchResult]()Xcode 也有相同的消息:“无法将类型的值转换PHFetchResult<_>为指定的 PHFetchResult”