SQLite的Swift基础封装:SQLiteDB
SQLiteDB 是基础的 SQLite 的 Swift 封装。SQLiteDB 非常简单,不提供任何高级的函数,不完全是 Swift 编写的,所以跟 Swift 调用 sqlite C API 的方法会有点不同。
- Create your SQLite database however you like, but name it
data.db
and then add thedata.db
file to your Xcode project. (If you want to name the database file something other thandata.db
, then change theDB_NAME
constant in theSQLiteDB
class accordingly.) - Add all of the included source files (except for README.md, of course) to your project.
- If you don't have a bridging header file, use the included
Bridging-Header.h
file. If you already have a bridging header file, then copy the contents from the includedBridging-Header.h
file in to your own bridging header file. - If you didn't have a bridging header file, make sure that you modify your project settings to point to the new bridging header file. This will be under the "Build Settings" for your target and will be named "Objective-C Bridging Header".
- Add the SQLite library (libsqlite3.0.dylib) to your project under the "Build Phases" - "Link Binary With Libraries" section.
let data = db.query("SELECT * FROM customers WHERE name='John'") let row = data[0] if let name = row["name"] { textLabel.text = name.string }
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!