ios - PHAssetCollectionChangeRequest : addAssets() now accepts NSFastEnumeration. 这个怎么实现?

标签 ios swift phasset

enter image description here

我的应用程序尝试从照片中导入图像并添加到相册。

但在最近的快速变化中。 addAssets() 接受参数作为 NSFastEnumeration。所以我得到一个错误,如图所示。

即使是 Apple API 文档也有相同的代码:https://developer.apple.com/library/prerelease/ios/documentation/Photos/Reference/PHAssetChangeRequest_Class/index.html#//apple_ref/occ/instp/PHAssetChangeRequest/placeholderForCreatedAsset

有什么替代方案或我现在如何添加 Assets ?

最佳答案

所以,我做了一些研究,并根据 NSHipsterNSEnumeration是由NSArrayNSSetNSDictionary实现的协议(protocol)。这表明如果您将 [assetPlaceholder] 转换为 NSArray,您将能够在该方法中使用它。而且,事实上,这个编译:

let enumeration: NSArray = [assetPlaceholder!]
albumChangeRequest!.addAssets(enumeration)

关于ios - PHAssetCollectionChangeRequest : addAssets() now accepts NSFastEnumeration. 这个怎么实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30818861/

相关文章:

ios - 在 Swift 中,如果你解开一个 "Implicitly Unwrapped Optional",这是一个双重解包吗?

ios - 为什么 SwiftUI View 模型应该用 @MainActor 注释?

ios - setContentOffset 从 ScrollView 的底部开始不起作用

ios - 如何在 fetch PHAssetCollection 语句中获取 "Camera Roll"、 "Videos"、 "Favorites"、 "Selfies"和 "Screenshots"- swift 4

ios - 当我在 Swift 中使用 PHAsset 时,我总是收到内存警告

ios - Storyboard,不再识别 UIControl 操作

ios - 无法为我的应用启用 Game Center

快速从相机胶卷中获取图像和视频

ios - 在 CALayers 上屏蔽 CAGradientLayer

ios - 使用 'vendored_frameworks' 和 'source_files' 用于 cocoapod 使用 'use_frameworks!'