'AuthDataResult'没有成员uid错误 [英] 'AuthDataResult' has no member uid error
问题描述
我正在Firebase数据库中创建一个新用户,并且试图为该用户设置更多值:名称,电子邮件,密码,DOB等.
I'm creating a new user within my firebase database, and I'm trying to set some more values to the user: name, email, password, DOB, etc.
/* Create User with Email and Password Provided */
Auth.auth().createUser(withEmail: emailTextfield.text!, password: passwordTextField.text!, completion: { (user, error) in
/* Handle errors that may occur while Creating user in Firebase */
if let error = error {
let alertController = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
let OKAction = UIAlertAction(title: "OK", style: .default) { (action: UIAlertAction!) in
}
alertController.addAction(OKAction)
self.present(alertController, animated: true, completion:nil)
self.signUpButton.isEnabled = true
return
} else {
SVProgressHUD.show(withStatus: "Loading")
let rootRef = Database.database().reference()
let userRef = rootRef.child("users").child(user!.uid)
当我尝试访问子级(user!.uid)时,在完成代码块内发生错误.我希望能够为其设置值,例如:
The error occurs within the completion block as I'm trying to access the child(user!.uid). I want to be able to set values to it such as:
rootRef.userRef.child("name").setValue(self.nameTextfield.text!)
但是我不能,因为访问(用户)参数时,回叫一定有问题. Xcode指出"AuthDataResult"没有成员uid.
but I can't since there must be an issue with the Callback when I'm accessing the (user) parameter. Xcode states 'AuthDataResult' has no member uid.
我们非常感谢您的帮助.
Any help is much appreciated.
推荐答案
就像大多数人已经说过的那样,它将是这样的:
As most people already said, it would be something like this:
user?.user.uid
这篇关于'AuthDataResult'没有成员uid错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!