2017-04-18 32 views
0

我必須顯示firebase的帖子,帖子在路徑中:Firebase,顯示文章的下一個路徑「self.dataBaseRef.child(」Posts「)。child(uid).childByAutoId()」

self.dataBaseRef.child("Posts").child(uid).childByAutoId() 

"uid" = FIRAuth.auth()!.currentUser!.uid 

dataBaseRef = FIRDatabaseReference! { 
    return FIRDatabase.database().reference() 
} 

在火力地堡後的出版工作的成功,但我不能讓這條道路,因爲我不能宣佈uid因爲是具體到每一個用戶。怎麼樣?

+0

如果我的回答幫助,將其標記請。讓別人知道,這是答案 –

回答

0

嘗試這樣的:

let dataBaseRef = FIRDatabase.database().reference(withPath: "Posts") 

dataBaseRef.observe(.value, with: { snapshot in 
     for item in snapshot.children { 
      let childSnap = item as! FIRDataSnapshot // do something you wants to 
      // childSnap contains item in Posts. So in cycle you will catch 
      // every post child node. From here you can get uid's 
      // and make a new observer 
     } 
}) 

希望它可以幫助