我正在使用另一个SO帖子中的代码(如下),它工作正常。我现在想做的是使用自定义元数据保存照片。特别是我已经从用户当前位置获得的位置数据。
func save(image: UIImage, imageName: String) {
self.checkAuthorizationWithHandler { (success) in
if success, self.assetCollection != nil {
PHPhotoLibrary.shared().performChanges({
let assetChangeRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
let assetPlaceHolder = assetChangeRequest.placeholderForCreatedAsset
if let albumChangeRequest = PHAssetCollectionChangeRequest(for: self.assetCollection) {
let enumeration: NSArray = [assetPlaceHolder!]
albumChangeRequest.addAssets(enumeration)
}
}, completionHandler: { (success, error) in
if success {
print("Successfully saved image to Camera Roll.")
} else {
print("Error writing to image library: \(error!.localizedDescription)")
}
})
}
}
}
我读到我的iOS不允许更改文件名(很好),但是拥有一些自定义数据对于我要实现的目标至关重要。
谢谢