Converting to Swift 3 (Swift and Firebase Project)

好久不见. 提交于 2019-12-25 08:07:53

问题


I have just updated my Xcode to Xcode8 and I have converted the project to swift 3.

In signIn function here:

  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")

                        }
                    })

I'm getting this error:

cannot convert value of type '(FIRUser?, NSError?) -> ()' to expected argument type 'FIRAuthResultCallback?'

What's the replacement of it in swift 3?


回答1:


Just replace it with :-

 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")

                    }
    })


来源:https://stackoverflow.com/questions/39562585/converting-to-swift-3-swift-and-firebase-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!