I have this FirebaseDatabase structure:
I need to retrieve the data from Firebase. Usually I use a function like this:
funfunc getWodsFromDataBase () {
print ("Get Wods From Data Base (AppDelegate)")
let wodDb = Database.database().reference().child("wods")
wodDb.observe(.childAdded) { (snapshot) in let snapValue = snapshot.value as! Dictionary<String, Any>
let girl_hero = snapValue["girl_hero"]!
let nombre = snapValue["nombre"]!
let wod = Wod(
girl_hero : girl_hero as! String,
nombre : nombre as! String,
)
self.wodsArray.append(wod)
}
}
Its easy to retrieve the first level values, but I don't know how to get every value of the second level ( exercices ) and how to update my wods struct that now are like this :
struct Wod {
var girl_hero : String
var nombre : String
init (){
self.girl_hero = ""
self.nombre = ""
}
init (
girl_hero : String,
nombre : String)
{
self.girl_hero = girl_hero
self.nombre = nombre
}
}
Can any one help me reWriting my Struct and getting the data from Firebase ?