- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图从一个 child 那里获取特定的值,然后从其他 child 那里获取其余的值。这就是我的数据库的样子。我想从 Bienmesabe
的键 longDescription
put 中获取值。
func getCakeDescription (from category: String, subcategory: String, handler: @escaping (_ cakeDescription: [GeneralInfo]) -> ()) {
var cakeDescriptionArray = [GeneralInfo]()
let trimCategory = category.trimmingCharacters(in: .whitespaces)
let trimSubcategory = subcategory.replacingOccurrences(of: " ", with: "")
REF_CAKES.child(trimCategory).child(trimSubcategory).observeSingleEvent(of: .value) { (returnedDescriptionSnapshot) in
guard let returnedDescriptionSnapshot = returnedDescriptionSnapshot.children.allObjects as? [DataSnapshot] else {return}
for cakesDesc in returnedDescriptionSnapshot{
let cakeLongDescription = cakesDesc.childSnapshot(forPath: "longDescription").value as! String
self.REF_CAKES.child("General").observeSingleEvent(of: .value) { (returnedGeneralSnapshot) in
guard let returnedGeneralSnapshot = returnedGeneralSnapshot.children.allObjects as? [DataSnapshot] else {return}
for generalInfo in returnedGeneralSnapshot{
let titleDelivery = generalInfo.childSnapshot(forPath: "TitleDelivery").value as! String
let orderAndDelivery = generalInfo.childSnapshot(forPath: "OrderAndDelivery").value as! String
let titleSizeAndPrice = generalInfo.childSnapshot(forPath: "TitleSizeAndPrice").value as! String
let sizeAndPrice = generalInfo.childSnapshot(forPath: "SizeAndPrice").value as! String
let titlePromo = generalInfo.childSnapshot(forPath: "TitlePromo").value as! String
let promotions = generalInfo.childSnapshot(forPath: "Promotions").value as! String
let cakesInfo = GeneralInfo(titleDevilery: titleDelivery, titleSizeAndPrice: orderAndDelivery, titlePromo: titleSizeAndPrice, sizeAndDelivery: sizeAndPrice, orderAndDelivery: titlePromo, promotions: promotions, cakeDescription: cakeLongDescription)
cakeDescriptionArray.append(cakesInfo)
}
}
}
handler(cakeDescriptionArray)
}
}
最佳答案
已解决
我阅读了文档并对其如何工作进行了一些测试,然后我得出了这个答案。我需要做的是改变我放置处理程序的位置。我还更改了数据库结构以更容易提取。下面是有关如何提取数据库中特定值的简单代码。
func getDescription (from category:String, and subcategory:String, handler: @escaping (_ cakeDescription: String)->()){
let trimSubcategory = subcategory.replacingOccurrences(of: " ", with: "")
REF_CAKES.child(category).child(trimSubcategory).observeSingleEvent(of: .value) { (cakeDescSnapshot) in
guard let cakeDescSnapshot = cakeDescSnapshot.children.allObjects as? [DataSnapshot] else { return }
for desc in cakeDescSnapshot{
if desc.key == "longDescription"{
handler(desc.value as! String)
}
}
}
}
还有其他方法,也可以使用查询方法。下面是一个例子
func getCakeDescription (from category: String, subcategory: String, handler: @escaping (_ cakeDescription: String) -> ()) {
let trimSubcategory = subcategory.replacingOccurrences(of: " ", with: "")
REF_CAKES.child(category).child(trimSubcategory).queryOrdered(byChild: "longDescription").observeSingleEvent(of: .childAdded) { (snapshot) in
handler(snapshot.value as! String)
})
}
}
关于ios - Firebase Swift iOS - 从 child 身上获取值(value),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47736853/
Closed. This question needs details or clarity。它当前不接受答案。 想改善这个问题吗?添加详细信息,并通过editing this post阐明问题。 4
我有followwing结构 some text Delete 是否可以使用指针事件禁用 div:除了保持按钮处于事件状态之外没有其他功能? 我试过 div.offline:not(.delete)
Here's my fiddle. 基本上我有一个父 div,需要在它周围有一个框阴影,由于各种原因,这个框阴影必须是一个伪元素。此框阴影会阻止捕获此父 div 的子项上的悬停事件。我该如何解决这个问
Cypress 在 Jenkins 中成功使用。从几周 Cypress 规范文件开始,它将永远挂起。它将卡在不同的规范文件中,这使得调试和查找失败的原因变得困难。有时它会成功运行所有规范文件。请帮帮我
我可能遇到了 DOM 和 jQuery 的问题。 我有这个 HTML 结构: 140,86
我有 View Controller A 和 View Controller B。A 具有 B 的序列。A 嵌入在导航 Controller 中。 导航栏在 A 上显示正常,但是在 B 上没有显示。我
试图解决一个有趣的 CSS 问题。 我正在尝试呈现一个最终必须位于相对父级(容器)内部的模态。我需要它是一个固定的叠加层,以便它覆盖整个视口(viewport)。下面包含的代码片段是为了简洁起见。 .
如何让一个自由落体的 Sprite 节点坐在另一个水平移动的 Sprite 体上? 现在两个 body 都发生了碰撞。但是水平运动的物体偏离了它的路径,自由落体撞击水平物体后下降。如何修复 Sprit
我想知道是否可以像这样对第 n 个 child 使用悬停 #gallery a img:hover { display: block; height:300px; width:
这个问题在这里已经有了答案: Why don't flex items shrink past content size? (5 个答案) 关闭 3 年前。 我有一个带有 flex: 1 的 fle
这个问题在这里已经有了答案: How to style the parent element when hovering a child element? (8 个答案) 关闭 9 年前。 所以我有
这个问题在这里已经有了答案: How to style the parent element when hovering a child element? (8 个答案) 关闭 9 年前。 所以我有
所以我的处境有点棘手。基本上我有这个可滚动的水平导航,它有一个 overflow-x: auto。导航具有与悬停时出现的下拉菜单的链接。 溢出会阻止下拉列表在未将其位置设置为 absolute 的情况
在 css 中有什么方法可以只选择悬停的容器子而不需要父级,这可以用 css 实现吗? 这就是我正在尝试的,应该选择最深的容器而不是我添加的 .decor 只是为了显示所选的 div。(这些 chil
有这个 parent : class BaseModel extends Eloquent { protected static $rules = []; public static
我有一个用作编辑器 View 的自定义窗口类,并且由于我直接处理键盘事件,所以我希望在顶部有一个标准的编辑控件来输入文本。我的问题很简单:我也想在用户点击自定义窗口类时获取焦点,所以我处理 WM_MO
我是一名优秀的程序员,十分优秀!