1

我当前的代码是用 Swift 3 编写的,我尝试通过 Xcode10.1 更改 Swift 4.2。SQLite 在更改版本上崩溃并且在旧代码上正常工作。

我正在尝试在 Cocoa macOS 应用程序中使用 SQLite.swift 和 Swift 检索表中的记录数。

let db = try Connection("\(pathh)/db.sqlite3")
let users = Table("users")
var count = try db.scalar(users.filter(userid == userid).count) 

但是,当执行此代码时(从按钮单击事件处理程序),将引发以下异常:

unrecognized token: ":" (code: 1)

当我尝试使用var count = try db.scalar("SELECT COUNT(*) FROM users WHERE userid=?",userid) as! Int64 时,会返回正确的结果。

任何和所有的帮助将不胜感激。提前致谢!

4

1 回答 1

1

在我的项目中,我需要更新的是我的 Podfile 中的以下内容:

pod 'SQLCipher', '~>4.2.0' pod 'SQLite.swift/SQLChiper', '~>0.12.0' pod update unrecognized token: ":" (code: 1) 后解决。

于 2020-04-23T04:16:18.727 回答