线程1:从UserDefaults获取值时出现EXC_BREAKPOINT错误

时间:2019-05-25 20:50:16

标签: ios swift

我正在尝试从UserDefaults获取数据并将其与来自javascript bridge的请求数据进行比较,但是一旦我运行该应用程序,它将挂起并在Thread 1: EXC_BREAKPOINT (code=1, subcode=0x100286b38)上显示此错误let getLastUserId = (UserDefaults.standard.object(forKey: "lastUserId") as? String)!可以解决这个问题吗?

  if message.name == "callbackRefreshApi"
        {
            let requestUserId = (message.body as? String)!
            let getLastUserId = (UserDefaults.standard.object(forKey: "lastUserId") as? String)!
            print("REFRESH TOKEN CALLED", requestUserId)
            print("REFRESH TOKEN getLastUserId", getLastUserId)

            UserDefaults.standard.removeObject(forKey: "token_api_called")
            UserDefaults.standard.synchronize()
            if !requestUserId.isEmpty && !getLastUserId.isEmpty {
                if requestUserId != getLastUserId {
                    print("REFRESH TOKEN FOR CHANGED USER")
                    self.savePreference(key: "lastUserId", value: requestUserId)
                }
                else {
                    print("REFRESH TOKEN FOR OLD USER")
                }
            }else{
                print("REFRESH TOKEN FOR NEW USER")
                self.savePreference(key: "lastUserId", value: requestUserId)
            }
            self.updateTokenAndLocationAPI(userId: requestUserId, action: "update")
        }

0 个答案:

没有答案