【发布时间】:2020-06-21 09:23:45
【问题描述】:
在下面的代码中,错误是这样来的。错误就像
“无法将'URL'类型的值转换为预期的参数类型'Bool']”
private func saveImages(){
let document = try !FileManager.default.url(for:.documentDirectory , in : .userDomainMask , appropriateFor: nil , create: true) //[error is = Cannot convert value of type 'URL' to expected argument type 'Bool']
print (document)
let imgUrl = document.appendingPathComponent("1.jpg" , isDirectory : true)
print(imgUrl.path)
if FileManager.default.fileExists(atPath: imgUrl.path){
do{
try UIImageJPEGRepresentation(UIImage(named : "1.jpg") !)?.write (to :imgUrl)
print("image added successfully")
}catch{
print("image not added")
}
}
}
【问题讨论】:
标签: ios swift xcode swift4 mobile-application