I am trying to create a user in Firebase with an email & password and upon successful creation of the user record, I would go and update tree with additional attributes as child nodes of the user's UID. Here is what I have in code:
@IBAction func registerPressed(sender: AnyObject) {
let connection = Firebase(url:"https://something.firebaseio.com")
connection.createUser(self.emailTxtField.text, password: self.passwordTxtField.text,
withValueCompletionBlock: { error, result in
if error != nil {
// There was an error creating the account
print("Error Creating Account...Please try again")
} else {
let uid = result["uid"] as? String
print("Successfully created user account with uid: \(uid)")
/*After creating the user, we want to update the tree with other attributes*/
let userAdditionalDetails = ["name": self.nameTxtField.text, "mobile": self.mobileTxtField.text, "username": self.usernameTxtField.text]
let usersRef = connection.childByAppendingPath("users")
let users = ["\(uid)": userAdditionalDetails]
usersRef.setValue(users)
}
})
}
Although am not sure if the above will work or not (since this my first work with Firebase SDK), I am getting the following error:
cannot convert value of type “[String: [String : String?]]” to expected argument type "AnyObject!"
I am unable of course to build the project due to the above error being triggered at line:
usersRef.setValue(users)
Any idea why this is happening and how to solve it?
Thanks in advance.