问题描述
-在图库中保存视频网址时 - 我也设置了读写权限。
错误:域=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 (将#修改为@)