ios - Getting all data in a Firebase column -
i created json database tree , can read specific values these codes. can see on table view "albert einstein"
ref.child("personel").child("name").observesingleevent(of: .value, with: { (snapshot) in if let item = snapshot.value as? string{ self.mylist.append(item) self.lessonstableview.reloaddata() } })
but, want see categories under personal column? this,
is there way or learn columns under "personal"
table view output must -> age, name, photo
you can iterate on snapshot, it's children , childrens keys
say have users node user
users user_0 fav_game: "wow" name: "leroy"
then keys of name: , fav_game:
let userref = self.ref.child("users").child("user_0") userref.observesingleevent(of: .value, with: { snapshot in child in snapshot.children { let snap = child as! datasnapshot let key = snap.key print(key) } })
prints
fav_game name
an important note is
for child in snapshot.children
because keep data (keys in case) in order. if snapshot dumped dictionary looses order.
Comments
Post a Comment