ios - 转换为 Swift 3(Swift 和 Firebase 项目)

标签 ios swift firebase firebase-authentication swift3

我刚刚将我的 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/

相关文章:

android - 远程配置备选方案 : Store UI specific parameters

swift - 如何转换 [String : Any] dictionary into a double?

ios - 将 UITableViewController 推送到导航堆栈失败

ios - GCM iOS 生产环境

ios - 在 iOS7 中重新排序 UICollectionView

html - 使用swift从ios上的文档目录将html文件加载到UIWebview

ios - 秒表和计时器

ios - 根据 if 语句更改 TableView 尺寸

swift - Arc4random 上较大的数量限制是否会降低加载速度?

ios - 使用来自 GoogleService-Info.plist 的信息访问 Firebase 前端