【发布时间】:2019-02-08 12:04:22
【问题描述】:
我的 firebase .observe 和 .observeSingleEvent 有问题。
ref = Database.database().reference()
let postRef = ref.child("posts").child("post")
print(postRef)
postRef.observeSingleEvent(of: .value) { (snapshot) in
if let postDict = snapshot.value as? [String : AnyObject] {
print(postDict)
}
}
我在 viewDidLoad() 中执行此操作。 'print(postRef)' 打印出我的 firebase 的正确路径。
https://-----.firebaseio.com/posts/post
在那之后,我什么也没得到。
子结构: child structure
为什么不打印“postDict”?
现在我在我的项目中看到了这个: CFNetwork/Foundation/Security.framework turns red!
【问题讨论】:
-
发布你的孩子结构,你可能看错了孩子。
-
另外,尝试在演员表之前打印快照,也许你在演员表上得到了零
-
@GustavoVollbrecht 我已经尝试过了。没有任何东西打印到控制台..
标签: ios swift firebase firebase-realtime-database