2016-06-13 80 views
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 
    } 
} 

它看起來像我在去錯了聲明數據庫的路徑。這有什麼不對?我如何使它工作?感謝您的幫助

enter image description here

+0

你在哪裏運行應用程序?模擬器還是真實設備? –

+0

@LucaDavanzo我使用模擬器 – SunShine

+0

閱讀下面的回答,您只需設置好的一個斷點,不用擔心! –

回答

0

您可以在您的代碼中的斷點,將停止執行。這不是一個錯誤,而是用於在代碼運行時檢查它。這被稱爲「調試」,非常有用。

您可以通過點擊就行左側的藍色標記刪除斷點,或者您也可以選擇繼續使用調試視圖(按「播放」按鈕)執行。

如果調試視圖未打開,可通過在視圖的底部按小箭頭打開。