“类型为'AuthDataResult的值?'没有成员'uid'''

时间:2018-09-27 11:17:29

标签: swift

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

1 个答案:

答案 0 :(得分:0)

替换

let uid = user.uid 

使用

let uid = user!.user.uid 

Docs中查看这里