2015年6月4日 星期四

swift 連結 sqlite how to example

整理一下網路上各家的文章,直接使用swift呼叫sqlite , 不用透過 fmdb

1. 先使用 firefox 的擴充套件:SQLite Manager 建立 sqlite database file







2. 在xcode建立single view application , 並將剛剛建立的sqlite database file拖拉到
    專案中



3. 在xcode做下設定


建立bridg header file , 作為 swift 與 object-c 的連結橋樑



 建立檔案,與命名檔案



 inclode sqlite3.h



 設定BridgingHeader.h的路徑,此處的路徑輸入務必正確






 設定 sqlite library



 檢查自己建立的sqlite database file是否已經被加入,
如果沒有被加入,會出現資料庫開啟的錯誤訊息




輸入下列程式碼



 已經開啟sqlite database




Related Posts Plugin for WordPress, Blogger...