How to rename a file using NSFileManager

后端 未结 4 1677
[愿得一人]
[愿得一人] 2020-12-24 05:51

I have a single file named a.caf in the documents directory. I would like to rename it when user types into a UITextField and presses change (t

4条回答
  •  -上瘾入骨i
    2020-12-24 06:22

    Worked on Swift 2.2

    func moveFile(pre: String, move: String) -> Bool {
        do {
            try NSFileManager.defaultManager().moveItemAtPath(pre, toPath: move)
            return true
        } catch {
            return false
        }
    }
    

提交回复
热议问题