【问题标题】:Swift and Firebase Database - Missing argument label 'andPriority' in callSwift 和 Firebase 数据库 - 调用中缺少参数标签“andPriority”
【发布时间】:2018-09-08 03:41:18
【问题描述】:

当用户在应用程序中注册时,下面的代码用于更新我的 firebase 数据库,假设在数据库中对用户进行身份验证并保存一个布尔值。执行此操作时出现以下错误(见下文)。

@IBAction func signupPressed(_ sender: UIButton) {

        Auth.auth().createUser(withEmail: emailEntryField.text!, password: passwordEntryField.text!) { (user, error) in
            if error == nil {

                //Show SVProgressHUD
                SVProgressHUD.show()

                //save User to Database
                let newUserInfo : [String:Any] = ["email":self.emailEntryField.text!, "state":true]
                self.ref.child("users").child(user?.user.uid).setValue(newUserInfo, withCompletionBlock: { (error, ref) in
                    print("New User Saved")
                }

                //Dismiss SVProgressHUD
                SVProgressHUD.dismiss()

                //move to info view controller
                self.performSegue(withIdentifier: "signupToInfo", sender: self)

            } else {

                print("Signup Unsuccessul")
                let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)
                let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)

                alertController.addAction(defaultAction)
                self.present(alertController, animated: true, completion: nil)

            }
        }
    }

【问题讨论】:

    标签: swift firebase firebase-realtime-database firebase-authentication


    【解决方案1】:

    块后面少了一个)

    self.ref.child("users").child(user?.user.uid).setValue(newUserInfo, withCompletionBlock: { (error, ref) in
      print("New User Saved")
    }
    

    在最后加上),像这样

    self.ref.child("users").child(user?.user.uid).setValue: newUserInfo, withCompletionBlock: { (error, ref) in
      print("New User Saved")
    })
    

    希望对你有帮助

    【讨论】:

    • 事情似乎总是那么简单...谢谢您的帮助
    猜你喜欢
    • 2014-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多