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