Lawris Lawris - 1 year ago 127
Swift Question

For each child in firebase

How can I list all the child in my firebase, so that I can count them and list each one on a table view ?

I've looked for the old documentation and the proposed code didn't worked.
I don't know if the new documentation is full or if there is something I can't see ?

Any help is appreciated.

Answer Source

With Firebase we have a snapshot with all the values from the database.

So, I first import the snapshot value as a Dictionary. Then, I use the count method.

        let mySnap = snapshot.value! as! [String:AnyObject]

        howManyDevices = mySnap.count

Simple as that.

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