如何解决当视频 url 保存在图库中时显示错误:Domain=NSCocoaErrorDomain Code=-1 "(null)" in swift
-在图库中保存视频网址时 - 我也设置了读写权限。
错误:域=NSCocoaErrorDomain Code=-1 "(null)" in swift。
private func saveVideoToPhotos(url : URL?) {
if let url = url,let urlData = NSData(contentsOf: url) {
let galleryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0];
let filePath = galleryPath.appending("/videoFileName.mp4")
print(filePath)
dispatchQueue.main.async {
urlData.write(toFile: filePath,atomically: false)
PHPhotoLibrary.shared().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL:URL(fileURLWithPath: filePath))
}) {
success,error in
if success {
print("Succesfully Saved")
} else {
dispatchQueue.main.async {
print(error.debugDescription)
self.popupAlert(title: "Request Failed.please try again later!",actionTitles: ["ok"],actionStyle: [.default],action: [{_ in }])
}
}
}
}
}else{
dispatchQueue.main.async {
self.popupAlert(title: "Request Failed.please try again later!",action: [{_ in }])
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。