ios - 使用 Swift 从 firebase 检索嵌套数据
问题描述
我如何访问嵌套的网站 url。我也不知道如何访问 Medium 部分下的 img。通过提供的图像中的代码,我可以毫无问题地访问其他信息:
ref = Database.database().reference()
ref.child("artists").queryOrderedByKey().observe(.value) { snapshot in
var temp = [Artist]()
for child in snapshot.children {
if let child = child as? DataSnapshot {
// decode json into Artist Struct
let model = try! FirestoreDecoder().decode(Artist.self, from: child.value as! [String : Any])
temp.append(model)
// print(model)
}
}
解决方案
Let ref = Database().database.refrence()
ref.child("TopNode").child("secondInerNode").observe(.value, with: {//stuff})
您将路径写入您拥有数据的位置,然后进行观察。
TopNode
secondInerNode
name: value;
推荐阅读
- python - python ML算法在滑坡敏感性评估中的数据集问题
- c# - 使 LINQ 表达式不区分大小写
- python - 某些语言在 kivy 中未正确处理/显示!有什么关系?
- python - Pyomo 中的稀疏索引集
- yii - 在 YII2 中捕获验证失败的 Google Analytics 事件
- css - 中心 svg 表示行文本
- mongodb - $lookup 管道中的 $match 始终返回所有文档,而不是过滤
- javascript - 如何为我的进度条创建价值指示器
- c++ - 在模板化函数中使用转发参数来执行具有默认参数的函数
- spring-boot - 无法在表格中显示上传的图像