gpt4 book ai didi

database - 从 firebase 数据库检索数据并快​​速操作

转载 作者:行者123 更新时间:2023-11-30 13:36:04 26 4
gpt4 key购买 nike

我开始使用 firebase 数据库已经有一段时间了。这是我的代码:

let fbRef = Firebase(url: "https://mylogin-fb.firebaseio.com")
var gatherData = fbRef.observeEventType(.ChildAdded, withBlock: {
snapshit in
print(snapshit.value)

}, withCancelBlock: {

error in
print(error.description)

})

这是结果:

{
"detail " = Swift;
"title " = programming;
}

我怎样才能简单地得到“Swift”或“programming”???

最佳答案

使用objectForKey检索数据。

就您而言:

let title = snapshot.value.objectForKey("title")
let detail = snapshot.value.objectForKey("detail")

print("Title : \(title), Detail : \(detail)")

关于database - 从 firebase 数据库检索数据并快​​速操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36056924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com