我将在下面附加使用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
。感谢。
答案 0 :(得分:9)
您好我有同样的问题,你有一个名为User的类,它与firebase中的类冲突只是改变
static var currentUser:User?
到
static var currentUser: FirebaseAuth.User?