我将在下面附上我使用 Firebase 的代码。遇到的错误如下:
FirebaseManager.swift:25:31: Cannot assign value of type
User?
to typeUser?
.
代码如下:
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
行。谢谢。
最佳答案
您好,我遇到了同样的问题,您有一个名称为 User 的类,它与 firebase 中的类冲突,只需更改
static var currentUser:User?
到
static var currentUser: FirebaseAuth.User?
关于ios - 火力地堡错误 : "cannot assign type User? to type User?",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44491130/