gpt4 book ai didi

ios - 错误 516 在 swift 中重命名文件

转载 作者:行者123 更新时间:2023-11-29 02:03:33 26 4
gpt4 key购买 nike

移动失败并出现错误:操作无法完成。 ( cocoa 错误 516。)

    var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! String

var getImagePath = paths.stringByAppendingPathComponent("Image.png")
var toImagePath = paths.stringByAppendingPathComponent("Image-"+sWordId+".png")

//let image = UIImage(named: getImagePath)
//i1.image = image

var error: NSError?
let filemgr = NSFileManager.defaultManager()

if filemgr.moveItemAtPath(getImagePath, toPath: toImagePath, error: &error) {
println("Move successful")
} else {
println("Moved failed with error: \(error!.localizedDescription)")
}

最佳答案

该错误意味着目标路径中已存在同名文件。

关于ios - 错误 516 在 swift 中重命名文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069281/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com