转换为Swift 3(Swift和Firebase项目)
我刚刚更新我的Xcode到Xcode8,我已经把项目转换为SWIFT 3。
在这里signIn函数:
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?'
什么是快速3更换它?
只需将其replace为: –
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") } })