gpt4 book ai didi

ios - 如何在 swift 中读取预加载的 sqlite 数据库

转载 作者:行者123 更新时间:2023-11-29 05:30:38 25 4
gpt4 key购买 nike

我正在尝试加载带有 .db3 扩展名的预加载 sqlite 数据库,但收到错误“意外发现 nil”

我将文件嵌入到 targetapp >> BuildPhases >> 复制捆绑资源。

let dat = Bundle.main.path(forResource: "resource", ofType: "db3")
let ddata = try! Connection(dat!, readonly: true)

do{
for row in try ddata.prepare("SELECT id FROM Categories") {
print("id\(row[0])")
}
}catch {
print(error.localizedDescription)
}

我想将数据加载到我的collectionView中

最佳答案

试试这个:

let dat = Bundle.main.path(forResource: "resource", ofType: "db3")!
let ddata = try! Connection(dat, readonly: true)

关于ios - 如何在 swift 中读取预加载的 sqlite 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57628876/

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