类型"AuthDataResult"的值没有成员"uid" [英] Value of type 'AuthDataResult' has no member ‘uid’
本文介绍了类型"AuthDataResult"的值没有成员"uid"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Firebase身份验证中访问用户的uid.我在代码中创建了一个createUser完成块,并在该块的末尾要检查我是否将其命名为firUser的用户.当我尝试在用户中添加firUser.uid
时,出现错误消息
I am trying to access a user's uid in Firebase Authentication. I created a createUser completion block in my code and at the end of the block I want to check for the user in which I named firUser. When I try to add firUser.uid
in my User I get the error message
类型为'AuthDataResult'的值没有成员'uid'"
"Value of type 'AuthDataResult' has no member ‘uid’"
下面是我编写的代码的副本,希望有人可以帮助我.
Below is a copy of the code I wrote hopefully some one can help me.
Auth.auth().createUser(withEmail: email, password: password, completion: { (firUser, error) in
if error != nil {
// report error
} else if let firUser = firUser {
let newUser = User(uid: firUser.uid, username: username, fullName: fullName, bio: "", website: "", follows: [], followedBy: [], profileImage: self.profileImage)
newUser.save(completion: { (error) in
if error != nil {
// report
} else {
// Login User
Auth.auth().signIn(withEmail: email, password: password, completion: { (firUser, error) in
if let error = error {
// report error
print(error)
} else {
self.dismiss(animated: true, completion: nil)
}
})
}
})
}
})
推荐答案
查看全文