gpt4 book ai didi

ios - 清除设备上的数据库(Sqlite)

转载 作者:行者123 更新时间:2023-11-30 13:42:20 29 4
gpt4 key购买 nike

我使用SwiftData在swift中创建sqlite数据库,数据库在模拟器上工作,但是当我想在真实设备上运行应用程序时,它不起作用,并且错误是没有这样的表,我该如何解决这个问题?

  let fileMan = NSFileManager.defaultManager()
if (fileMan.fileExistsAtPath(dbPath)){
if let source = NSBundle.mainBundle().resourcePath?.stringByAppendingPathComponent(databaseStr){
if (fileMan.fileExistsAtPath(source)){

print("SQLiteDB - file \(databaseStr) not found in bundle")
} else {
// var error: NSError?
do {
try fileMan.copyItemAtPath(dbPath, toPath: source )


} catch _ {

}

}

}

}
return dbPath

}

最佳答案

从设备中删除应用程序并清理项目在很多情况下都会有所帮助。

如果仍然不起作用,请尝试打开 sqlite 数据库。 firefox sqlite-manager

但我认为最简单的解决方案是删除数据库并创建一个新数据库。删除后,您还需要从设备和模拟器中删除该应用程序。

关于ios - 清除设备上的数据库(Sqlite),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35411004/

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