gpt4 book ai didi

ios - Swift 中的持久化文件

转载 作者:行者123 更新时间:2023-11-30 12:44:53 24 4
gpt4 key购买 nike

我有一个文件(例如“file.ieee”),它嵌入在我的应用程序中(在构建时包含在 Assets 中) )。

应用程序将从网络服务获取新版本并将其存储在本地临时目录中(请参阅下面的代码)。

如何替换(并保留)新版本?

    // Construct the NSURL for the download location.
let downloadingFilePath = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("downloaded-file.ieee")

我基本上想将downloaded-file.ieee的内容复制到“file.ieee”中。

最佳答案

FileManager's class method copyItem(at:to:)

do {
try FileManager.default.copyItem(at: temporaryURL, to: permanentURL)
} catch {
print(error)
}

关于ios - Swift 中的持久化文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41767072/

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