Firebase错误:“无法分配类型用户?键入用户?”

时间:2017-06-12 03:45:17

标签: ios swift variables firebase

我将在下面附加使用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。感谢。

1 个答案:

答案 0 :(得分:9)

您好我有同样的问题,你有一个名为User的类,它与firebase中的类冲突只是改变

static var currentUser:User?

static var currentUser: FirebaseAuth.User?