ios - Firebase 注册函数中无法将类型 'User?' 的值转换为预期参数类型 'User!' 错误

标签 ios swift xcode firebase firebase-authentication

我最近将 Swift 2.0 项目更新为 Swift 3.0,现在我的 Firebase 注册函数出现此错误(代码之前肯定有效)。

func signUp(_ email: String, username: String, password: String, data: Data!) {

    Auth.auth().createUser(withEmail: email, password: password, completion: { (user, error) in

        if error == nil {

            // error here
            self.setUserInfo(user, username: username, password: password, data: data)
        }else {
            print(error!.localizedDescription)
        }
    })
}

非常感谢您对此提供的任何帮助。

谢谢!

最佳答案

    FIRAuth.auth()?.createUser(withEmail: self.emailtextfield.text!, password: self.passwordtextfield.text!, completion: { (user, error) in
          if let fireBaseError = error {
                self.emailerror.isHidden = false
                self.errorlabel.text = "\(fireBaseError.localizedDescription)"
                return


         }
})

这对我有用

关于ios - Firebase 注册函数中无法将类型 'User?' 的值转换为预期参数类型 'User!' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46894696/

相关文章:

ios - 为什么当我的基础数据源更新时 SwiftUI 会自动向后导航,我该如何避免这种行为?

ios - 当 TestFlight 应用程序过期时会发生什么?

ios - 为什么具有 ISO 8601 值的日期时间字段在 iOS webkit 浏览器中不起作用?

swift - SIGABRT 与 Xcode 使用 Swift

ios - ABPersonRemoveImageData 在本地工作但不更新 iCloud

ios - UICollectionViewCell 内 ImageView 的边框宽度问题

swift - 从 ReactiveCocoa 2.4.7 跳到 ReactiveCocoa 5.0.0

ios - UIViewPropertyAnimator 未按预期工作

ios - 如何在 TableviewController 中添加一个按钮?

ios - xcode : storyboard does not reflect changes made in code in ViewController. swift