Adrien Zier
Adrien Zier

Reputation: 817

Firebase Swift 3 get list of child in a array

I'm trying to the get a list data from the Firebase Database then convert as a array. I looked at many examples online but never managed to work (as far as I know) the code below is the closet I could get with 1 error.

ref.child("").observe(.childAdded, with: { (snapshot) -> Void in

        var newItems = [FDataSnapshot]() //Error: Use of unresolved identifier 'FDataSnapshot'

        for item in snapshot.children {
            newItems.append(item as! FDataSnapshot)
        }

    })

I just cant find a answer since those past 2 days.

Thanks in advance for helping!

Upvotes: 2

Views: 2616

Answers (1)

Dravidian
Dravidian

Reputation: 9945

Try this:-

ref.child("").observe(.childAdded, with: { (snapshot) in

    var newItems = [FIRDataSnapshot]() 

    for item in snapshot.children {
        newItems.append(item as! FIRDataSnapshot)
    }

})

Upvotes: 7

Related Questions