【问题标题】:JSON Store can't read when setting password设置密码时无法读取 JSON 存储
【发布时间】:2021-12-22 07:18:35
【问题描述】:

我使用密码打开收藏,如下所示:

let options = JSONStoreOpenOptions()
            options.username = username
            options.password = paz
          do {
              try JSONStore.sharedInstance().openCollections([store], with: options)
          } catch let error as NSError {
            print(error)
          }

当我使用 Id 键找到时,无法解码 JSON 返回并且我得到错误域=JSON_STORE_EXCEPTION Code=22 "(null)"。我在没有密码的情况下测试了打开收藏,效果很好。

 let decoder = JSONDecoder()
        do {
               if let results = try store.find(withIds: [1], andOptions: nil) as? [[String: Any]],
                let result: [String: Any] = results.first,
                let json: [String: Any] = result["json"] as? [String: Any] {
                let jsonData = try JSONSerialization.data(withJSONObject: json, options: [])
                return try decoder.decode(type, from: jsonData)
            }
        } catch let error {
            print(error)
        }

使用密码有什么遗漏的吗?

【问题讨论】:

    标签: ios swift jsonstore


    【解决方案1】:

    我解决了这个问题。这是因为项目中同时安装了SQLCipher和sqlite。如果同时安装了SQLCipher和sqlite,需要在OTHER_LDFLAGS中的SQLCipher后面设置sqlite。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-19
      • 2011-02-05
      • 2021-07-26
      • 2018-10-09
      • 1970-01-01
      • 2021-03-09
      • 2014-07-09
      • 2014-10-13
      相关资源
      最近更新 更多