iShaalan iShaalan - 10 months ago 60
iOS Question

SetValue is not behaving as expected

I am using Firebase in an iOS app written using Swift.

static func createUserRecord(uid: String, user: User){
let userDictionary = user.getJSON()

This code was working just fine before I release my app and after releasing the app I could not get user records added anymore, All other functionalities of the app are working fine, including saving and retrieving some data. Can anyone spot the error in this code?

works even if the path was not there ? e.g. if the path
is there, and I called
. Will this work?


Calling setValue() will create the path if it doesn't exist yet.

It seems more likely that your user.getJSON() contains something that is invalid according to the database (or your security rules).

You'll want to attach a completion block to detect this.

For an example of how to do this, see Detect errors when writing a value on iOS.