gpt4 book ai didi

swift - 如何使用 swift 为 sqlite 提供数据库路径

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

我尝试下面的代码来创建数据库,但这在运行时返回我线程断点错误,接近让part1DbPath =“/用户/用户名/文档/”

import UIKit

class ViewController: UIViewController {
let part1DbPath = "/Users/username/Documents/"

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func openDatabase() -> COpaquePointer {
var db: COpaquePointer = nil
if sqlite3_open_v2(part1DbPath, &db, SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE, "") == SQLITE_OK {
print("Successfully opened connection to database at \(part1DbPath)")
return db
} else {
print("Unable to open database. Verify that you created the directory described " +
"in the Getting Started section.")
}
return db
}
}

看起来我在声明数据库路径时出错了。这有什么问题吗?我该如何让它发挥作用?感谢您的帮助

enter image description here

最佳答案

您可以在代码中设置断点来停止执行。这不是一个错误,而是用于在代码运行时检查它。这称为“调试”并且非常有用。

您可以通过单击该行左侧的蓝色标记来删除断点,也可以选择使用“调试” View 继续执行(按“播放”按钮)。

如果调试 View 未打开,可以通过按 View 底部的小箭头将其打开。

关于swift - 如何使用 swift 为 sqlite 提供数据库路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37783408/

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