Ios 如何使用Photos.Framework将自定义数据保存到PHAsset
Im使用照片框架保存和检索设备相册中的视频 在保存视频时,我想添加一些自定义数据,如:id、名称、描述等。。。 并在从相册中检索时获取所有这些数据 可能吗 我用来保存视频的代码是:Ios 如何使用Photos.Framework将自定义数据保存到PHAsset,ios,swift,video,phasset,phphotolibrary,Ios,Swift,Video,Phasset,Phphotolibrary,Im使用照片框架保存和检索设备相册中的视频 在保存视频时,我想添加一些自定义数据,如:id、名称、描述等。。。 并在从相册中检索时获取所有这些数据 可能吗 我用来保存视频的代码是: func saveVideo(url: URL, completionHandler: @escaping (Bool, Error?) -> ()) { if assetCollection == nil { return // If there was
func saveVideo(url: URL, completionHandler: @escaping (Bool, Error?) -> ()) {
if assetCollection == nil {
return // If there was an error upstream, skip the save.
}
PHPhotoLibrary.shared().performChanges({
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
let assetPlaceholder = assetChangeRequest?.placeholderForCreatedAsset
let albumChangeRequest = PHAssetCollectionChangeRequest(for: self.assetCollection)
albumChangeRequest?.addAssets([assetPlaceholder] as NSFastEnumeration)
}, completionHandler: {
saved, error in
completionHandler(saved,error)
})
}