【问题标题】:Is the fetchAssetCollections method deprecated in latest version of Photos library?最新版本的照片库中是否不推荐使用 fetchAssetCollections 方法?
【发布时间】:2020-01-17 19:10:18
【问题描述】:

我在 XCode 中创建了一个命令行项目

我认为这是 swift 中的有效代码

 let all = PHAssetCollection.fetchAssetCollections(with: .smartAlbum, subtype: .smartAlbumUserLibrary,  

但是,当我现在尝试时,自动完成功能并未将 fetchAssetCollections 列为选项。

我的构造函数中的类似问题

这里是代码片段

import Foundation
import Photos

class PhotoExplorer {

    init() {
        PHPhotoLibrary.shared().register(self)
    }

    func listAssetsInPhoto() -> PHCollection {
        let fetchOptions = PHFetchOptions()
        PHAssetCollection.fetch //  <- To be complete

    }
}

这是我的构建设置

我添加了import PhotosUI,但没有帮助。

我做错了吗? API 有变化吗?

【问题讨论】:

  • 刚刚在我这边试过,它应该可以正常工作,这是一个class 函数,没关系。似乎只是完成问题你试过重启XCode吗?
  • 我已经重启了xcode。还是同样的问题。

标签: swift xcode macos xcode10 xcode10.3


【解决方案1】:

修复它的唯一方法是重新创建项目。

【讨论】:

    猜你喜欢
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2014-04-02
    相关资源
    最近更新 更多