gpt4 book ai didi

swift - "Value of type ' AuthDataResult ' has no member ' uid '"错误

转载 作者:IT王子 更新时间:2023-10-29 05:45:48 24 4
gpt4 key购买 nike

有人可以帮我解决这个问题吗?第一个错误是“‘authdataresult’类型的值没有成员‘uid’”。

Auth.auth()?.signIn(withEmail: email, password: password, completion:

所以我删除了问号来解决问题并且成功了!但在那之后,又出现了另一个错误,它说“‘AuthDataResult’类型的值没有成员‘uid’”。我知道,这很烦人。

self.userUid = user.uid

哦,还有另一个错误,它在我的项目中已经存在很长时间了,所以现在我忽略了它,但是如果有人知道如何修复它,请告诉我。错误是“只能声明实例方法@ibaction”。

@IBAction func signInTapped(_ sender: Any) {

我不知道为什么,但也许这 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()
}
});
}
}
}
}

我发誓,我尝试修复它,然后突然出现 9 个错误。顺便说一下,我使用的是 Xcode 9、Swift 4,而且我的 Cocoapods 是最新的。对于所有编辑、评论或判断问题的人,请注意这不是重复的问题。它们是 2 个不同的错误。

最佳答案

似乎 Google 在 5.0.0 更新中对 Firebase Auth 做了一些更改。这对我有用:

self.userUid = user.user.uid

我不确定更改的目的是什么,但它仍然完全一样。

关于swift - "Value of type ' AuthDataResult ' has no member ' uid '"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50317730/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com