0
我想下面的代碼來創建數據庫,但是這將返回我在運行時斷線點誤差,近 let part1DbPath = "/Users/username/Documents/"
如何使用給予了SQLite數據庫路徑迅速
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
}
}
它看起來像我在去錯了聲明數據庫的路徑。這有什麼不對?我如何使它工作?感謝您的幫助
你在哪裏運行應用程序?模擬器還是真實設備? –
@LucaDavanzo我使用模擬器 – SunShine
閱讀下面的回答,您只需設置好的一個斷點,不用擔心! –