【发布时间】:2018-05-15 22:50:51
【问题描述】:
我正在我的 firebase 数据库中创建一个新用户,并尝试为该用户设置更多值:姓名、电子邮件、密码、DOB 等。
/* 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)
当我试图访问孩子(用户!.uid)时,错误发生在完成块内。我希望能够为其设置值,例如:
rootRef.userRef.child("name").setValue(self.nameTextfield.text!)
但我不能,因为当我访问 (user) 参数时,回调一定有问题。 Xcode 声明“AuthDataResult”没有成员 uid。
非常感谢任何帮助。
【问题讨论】:
标签: swift firebase firebase-authentication