ios - ios - swift,如何在註冊時檢查用戶是否已經註冊

134 3

如何檢查用戶是否已經註冊。

在LoginViewcintroller loginnservice中,我保存uid值:


self.Uid = json["id"] as? String


KeychainWrapper.standard.set(emailL ??"", forKey:"user_email")


KeychainWrapper.standard.set(self.Uid!, forKey:"Uid")



這裡在RegisterViewController registerService中檢索uid值,對於已經註冊的人,在uid中也為nil ,為何?


do{


let userId: String? = KeychainWrapper.standard.string(forKey:"Uid")


print("login userid (userId)")


if userId != nil{


 AlertFun.ShowAlert(title:"Title", message:"user exist", in: self)


}


else{


 let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! [String: Any]


 print("go to otp service!!!")


 self.otpField = json["otp"] as? Int


}



}catch{


print("error")


}



我該如何在rgistrservice中獲取已經註冊的uid 。

时间: 原作者:

54 5


var Uid = json["id"] as? String // `var Uid` is a local variable


KeychainWrapper.standard.set(self.Uid!, forKey:"Uid") // `self.Uid` is a property on self



通過設置屬性來修復它,而不是創建單獨的變數,


self.Uid = json["id"] as? String


KeychainWrapper.standard.set(self.Uid!, forKey:"Uid")



原作者:
...