简体   繁体   中英

JSON Store can't read when setting password

I use password to open collection like below:

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

When I find with Id key, can't decode JSON return and I got Error Domain=JSON_STORE_EXCEPTION Code=22 "(null)". I tested without password to open collection, It works well.

 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)
        }

Is there anything do I missed out for using with password?

I solved the problem. It is because of SQLCipher and sqlite both installed in project.If SQLCipher and sqlite both installed, need to set sqlite after SQLCipher in OTHER_LDFLAGS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM