我有这个代码从firebase数据库获取数据:
FIRDatabase.database().reference().child("Root").child("User1").child("chat1")
.observeSingleEvent(of: .value , with: { snapshot in
if snapshot.exists() {
let recent = snapshot.value as! NSDictionary
print(recent)
})
快照的结果有问题, print(recent)
有时打印那个孩子的所有值(10个值),这是我想要的东西,但有时候它只打印那个孩子的两个值,我不知道为什么 .
如何解决这个问题?
这是我的数据库结构:
1 回答
由于我无法发表评论,我只是想问一些问题,我稍后会删除此答案,但您的数据是否同步?你有没有把方法称为你的参考.keepSynced(true)?