火力底座错误:"cannot assign type User? to type User?"



我将在下面附加使用Firebase的代码。遇到的错误如下:

FirebaseManager.swift:25:31:无法分配类型为User?的值 键入 User?

这是代码:

class FirebaseManager: NSObject {
    static let databbaseRef = Database.database().reference()
    static var currentUserId:String = ""
    static var currentUser:User?
    static func Login(email:String, password:String, completion: @escaping (_ success:Bool) -> Void) {
        Auth.auth().signIn(withEmail: email, password: password, completion: { (user,error) in
            if let error = error {
                print(error.localizedDescription)
                completion(false)
            } else {
                currentUser = user
                currentUserId = (user?.uid)!
                completion(true) }

请帮忙。问题出在currentUser = user 中。谢谢。

嗨,

我遇到了同样的问题,您有名称为用户的类,并且它与Firebase的类冲突只是更改

static var currentUser:User?

static var currentUser: FirebaseAuth.User?

相关内容

最新更新