How to extract child of node in data snapshot

前端 未结 1 1020
春和景丽
春和景丽 2021-01-27 05:48

My firebase set up is as such:

Parent_node:{
    Type:{
        1476663471800:{ //This is a timestamp = Int64(date.timeIntervalSince1970 * 1000.0) 
            u         


        
1条回答
  •  盖世英雄少女心
    2021-01-27 06:19

    First of all use snapshot.value?.allValues to get values and than parse it...

      if snapshot.exists() {
         for value in (snapshot.value?.allValues)!{
              print(value) // you get [uid: USERS_UID] here
    
              // ... parse it to get USERS_UID
              print("user_id -- \(value["uid"])")
          }
      }
    

    With this method, order of child might be different. For ordered nodes, you can use snapshot.child

    0 讨论(0)
提交回复
热议问题