我刚刚将我的 Xcode 更新为 Xcode8,并将项目转换为 swift 3。
在这里登录函数:
Firth. Auth()?.signIn(withEmail: self.EmailTF.text!, password: self.PasswordTF.text!, completion: { (user: FIRUser?, error: NSError?) in
if let error = error {
print(error.localizedDescription)
} else {
self.ref.child("UserProfile").child(user!.uid).setValue([
"email": self.EmailTF.text!,
"name" : self.NameTF.text!,
"phone": self.PhoneTF.text!,
"city" : self.CityTF.text!,
])
print("Sucess")
}
})
我收到这个错误:
cannot convert value of type '(FIRUser?, NSError?) -> ()' to expected argument type 'FIRAuthResultCallback?'
它在 swift 3 中的替代品是什么?
最佳答案
只需将其替换为:-
FIRAuth.auth()?.signIn(withEmail:self.EmailTF.text!, password: self.PasswordTF.text!, completion: { (user, err) in
if let error = err {
print(error.localizedDescription)
} else {
self.ref.child("UserProfile").child(user!.uid).setValue([
"email": self.EmailTF.text!,
"name" : self.NameTF.text!,
"phone": self.PhoneTF.text!,
"city" : self.CityTF.text!,
])
print("Sucess")
}
})
关于ios - 转换为 Swift 3(Swift 和 Firebase 项目),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39562585/