如何使用swift更改文件扩展名?

时间:2019-01-24 07:46:20

标签: ios swift

我正在使用快速代码,但文件扩展名未更改。

这是我的快捷代码

let url = NSURL(fileURLWithPath: outputURL.path).deletingPathExtension?.appendingPathExtension("mp3")

1 个答案:

答案 0 :(得分:3)

您只是创建一个//some code setBackgroundColor(R.color.colorPrimary) //some code ,然后更改该URL。您实际上并没有对任何文件进行操作。

要重命名文件,请调用FileManager.default.moveItem(at:to:)。将文件URL作为第一个参数传递,并将具有新名称的文件URL作为第二个参数传递。

URL