gpt4 book ai didi

swift - ''Value of type ' AuthDataResult ?' has no member ' uid '''

转载 作者:行者123 更新时间:2023-11-30 11:07:34 30 4
gpt4 key购买 nike

@IBAction func SignUpBtn_TouchUpInside(_ sender: Any) {

Auth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!, completion: { (user: AuthDataResult?, error:Error?) in
if error != nil{
print(error?.localizedDescription)
return

}

let ref = Database.database().reference()
let usersRenfence = ref.child("users")

let uid = user.uid
//(HERE IS WRONG, I DONT KNOW WHAT SHOULD I DO. It's my first time study code.)
let newUserRefernce = ref.child(uid)
newUserRefernce.setValue{["username": self.usernameTextField.text!, "email": self.emailTextField.text!]

print("description: \(newUserRefernce.description())")

最佳答案

替换

let uid = user.uid 

let uid = user!.user.uid 

看这里Docs

关于swift - ''Value of type ' AuthDataResult ?' has no member ' uid ''',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52535738/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com