Swift 3.x iOS 10。
尝试了解 firebase 中的数据库。将一些 JSON 数据导入到我的应用程序中并设法将其读回。这是代码。
let rootRef = Database.database().reference(withPath: "0")
print("\(rootRef.key)")
let nextRef = rootRef.child("identity")
print("\(nextRef)")
nextRef.observe(.value, with: { snapshot in
print("\(snapshot.value)")
})
这有效,我的数据看起来像这样......
但是,如果我想遍历数据库,查看记录 2、记录 3 等,而我不确定实际有多少记录,该怎么做。
最佳答案
好的,我找到了,很好用的东西......
let rootRef = Database.database().reference()
rootRef.observe(.value, with: { snapshot in
print("dump \(snapshot.children.allObjects)")
})
我发帖是为了后代:)
关于ios - 遍历 firebase 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46412596/