Why I getting an error message in the line that says:
usersReference.updateChildValues(values, withCompletionBlock: { (err, ref)
The error message says:
Expression implicitly coerced from '[String : String?]' to '[AnyHashable : Any]'
What changes could I make to my code to prevent the error message?
Here is all of my code from the view controller:
import UIKit
import Firebase
import FirebaseAuth
class RegisterViewController: UIViewController {
private var ref: DatabaseReference! // референс к БД
@IBOutlet weak var emailField: UITextField!
@IBOutlet weak var passwordField: UITextField!
@IBOutlet weak var firstNameField: UITextField!
@IBOutlet weak var lastNameField: UITextField!
@IBOutlet weak var cityField: UITextField!
@IBOutlet weak var telNumField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
ref = Database.database().reference() // инициализация БД
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func nextButtonPressed(_ sender: Any) {
Auth.auth().createUser(withEmail: self.emailField.text!, password: self.passwordField.text!) { (user, error) in
if error != nil {
print(error!)
self.showAlert(title: "Error!", msg: "Invalid information", actions: nil)
return
}
print("Registration succesfull")
guard let uid = user?.uid else { //доступ к ID пользователя
return
}
self.ref = Database.database().reference() // инициализация БД
let usersReference = self.ref.child("users").child(uid)
let values = ["firstname": self.firstNameField.text, "lastname": self.lastNameField.text, "email": self.emailField.text, "city": self.cityField.text, "telnumber": self.telNumField.text]
usersReference.updateChildValues(values, withCompletionBlock: { (err, ref) in
if let err = err {
print(err)
return
}
print("Saved user successfully into Firebase db")
})
}
}