iShaalan iShaalan - 1 year ago 97
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download