Yann Massard Yann Massard - 1 year ago 116
Swift Question

firebase snapshot key for children autoids

I have the following structure :

-kojasd- <----- child by autoid key name for folder
-kjofs- <----- child by aytoid key name for folder

how can I get the key value of the childbyautoid() in a snapshot.children loop ?

here s a bit of code to explain :

for items in snap.children {
let key = items.key as! String // DOESN T WORK

let value = items.value!!["property"] as! String


in this code, snap refers to DATA

I thought that it would be easy to get this key value, but I m stucked here since a long time, any help ?? :)


Answer Source

ok, found a solution, I had to pass the snap into a new fdatasnapshot to get its key

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