【问题标题】:SQLite.swift: Can't retrieve table count due unrecognized token: ":" (code: 1)SQLite.swift:由于无法识别的令牌无法检索表计数:“:”(代码:1)
【发布时间】:2020-08-04 06:50:01
【问题描述】:

我当前的代码是用 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 ,返回正确的结果。

我们将不胜感激。提前致谢!

【问题讨论】:

  • 谁能帮忙解决?

标签: sqlite.swift xcode10.1 xcode11.4


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 2016-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多