Mar*_*llo 9 swift firebase-authentication
有人可以帮我解决这个问题吗?第一个错误是"类型'authdataresult'的值没有成员'uid'".
Auth.auth()?.signIn(withEmail: email, password: password, completion:
Run Code Online (Sandbox Code Playgroud)
所以我删除了问号以解决问题并且它有效!但在那之后,另一个错误来了,它说"类型'AuthDataResult'的值没有成员'uid'".我知道,这很烦人.
self.userUid = user.uid
Run Code Online (Sandbox Code Playgroud)
哦,还有另一个错误,它已经在我的项目中很长一段时间所以现在我忽略了它但是如果有人知道如何修复它请告诉我.错误是"只有实例方法可以声明为@ibaction".
@IBAction func signInTapped(_ sender: Any) {
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但也许3个错误是连接的.我不知道.救命.所以现在我又被卡住了.这是整个混乱编码的东西.
import UIKit
import Firebase
class ViewController: UIViewController {
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
var userUid: String!
func goToCreateUserVC(){
performSegue(withIdentifier: "SignUp", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "SignUp" {
if let destination = segue.destination as? userVC {
if userUid != nil {
destination.userUid = userUid
}
if emailField.text != nil {
destination.emailField = emailField.text
}
if passwordField.text != nil {
destination.passwordField = passwordField.text
}
}
}
@IBAction func signInTapped(_ sender: Any) {
if let email = emailField.text, let password = passwordField.text {
Auth.auth().signIn(withEmail: email, password: password, completion: { (user,error) in
if error == nil {
if let user = user {
self.userUid = user.uid
self.goToCreateUserVC()
}
} else {
self.goToCreateUserVC()
}
});
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
就像我发誓,我试图解决它,然后突然出现了9个错误.顺便说一句,我使用的Xcode 9,斯威夫特4,和我的CocoaPods均达到最新.对于那些编辑,评论或判断问题的人,请不要重复这个问题.它们是2个不同的错误.
小智 28
谷歌似乎已经使用5.0.0更新对Firebase Auth进行了一些更改.这对我有用:
self.userUid = user.user.uid
Run Code Online (Sandbox Code Playgroud)
我不确定改变的重点是什么,但它仍然完全相同.
| 归档时间: |
|
| 查看次数: |
4542 次 |
| 最近记录: |