Xcode Firebase |无法将类型"AuthDataResult"的值转换为预期的参数类型“用户"

Xcode Firebase |无法将类型

问题描述:

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

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