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



原作者:
...