【问题标题】:Conversion errors from Swift 3.0 to Swift 4.2 at SQLitt.Swift unregonized tokenSQLitt.Swift unregonized token 从 Swift 3.0 到 Swift 4.2 的转换错误
【发布时间】:2020-08-05 00:12:17
【问题描述】:

我当前的代码是用 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 时,会返回正确的结果。 但是这个usu-age返回错误

no such table tablename (code:1)

对于一些表。

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

【问题讨论】:

    标签: ios xcode swift4.2 sqlite.swift xcode11.4


    【解决方案1】:

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

    pod 'SQLCipher', '~>4.2.0'
    pod 'SQLite.swift/SQLChiper', '~>0.12.0'
    

    pod 更新后 无法识别的令牌:“:”(代码:1)已解决。

    【讨论】:

      猜你喜欢
      • 2020-07-30
      • 1970-01-01
      • 1970-01-01
      • 2020-01-17
      • 1970-01-01
      • 1970-01-01
      • 2018-05-20
      • 2019-09-03
      • 1970-01-01
      相关资源
      最近更新 更多