gpt4 book ai didi

swift - Xcode 火力地堡 |无法将类型“AuthDataResult”的值转换为预期的参数类型 'User'

转载 作者:行者123 更新时间:2023-11-28 13:50:26 25 4
gpt4 key购买 nike

我真的尝试了所有可能的选择来编写它,但我似乎无法找出解决方案。

func signup(email: String, password: String) {
Auth.auth().createUser(withEmail: emailText.text!, password: passwordText.text!, completion: { (user, error) in
if error != nil {
print(error!)
}else {
self.createProfile(user!) //Here's the problem described in the title //
let homePVC = RootPageViewController()
self.present(homePVC, animated: true, completion: nil)
}
})
}

func createProfile(_ user: User) {
let newUser = ["email": user.email, "photo": "https://firebasestorage.googleapis.com/v0/b/ecoapp2.appspot.com/o/photos-1.jpg?alt=media&token=ee104f2d-ed9a-4913-8664-04fd53ead857"]
self.databaseRef.child("profile").child(user.uid).updateChildValues(newUser) { (error, ref) in
if error != nil {
print(error!)
return
}
print("Profile successfully created")
}
}

最佳答案

你需要

Auth.auth().createUser(withEmail: email, password: password) { authResult, error in
// ...
guard let user = authResult.user else { reurn }
self.createProfile(user)
}

func createProfile(_ user: FIRUser ) { --- }

关于swift - Xcode 火力地堡 |无法将类型“AuthDataResult”的值转换为预期的参数类型 'User',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54715229/

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