Xcode Firebase |无法将类型"AuthDataResult"的值转换为预期的参数类型“用户" [英] Xcode Firebase | Cannot convert value of type'AuthDataResult' to expected argument type 'User'

查看:58
本文介绍了Xcode Firebase |无法将类型"AuthDataResult"的值转换为预期的参数类型“用户"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上尝试过尝试所有可能的选项来编写它,但是我似乎无法找出解决方案.

I tried literally tried every possible option to write it, but I can't seem to figure out the solution.

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 ) { --- }

这篇关于Xcode Firebase |无法将类型"AuthDataResult"的值转换为预期的参数类型“用户"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆