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

时间:2016-06-13 06:51:27

标签: swift sqlite

我尝试使用下面的代码来创建数据库,但这会在运行时,附近返回我的线程断点错误 let part1DbPath = "/Users/username/Documents/"

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

1 个答案:

答案 0 :(得分:0)

您可以在代码中设置将暂停执行的断点。这不是错误,但用于在代码运行时检查代码。这称为“调试”,非常有用。

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

如果调试视图未打开,可以通过按视图底部的小箭头打开它。