ios - Swift firebase .observe or .observeSingleEvent won't work
问题描述
I've got a problem with my firebase .observe and .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)
}
}
I do this in my viewDidLoad(). the 'print(postRef)' prints the right path to my firebase.
https://-----.firebaseio.com/posts/post
After that I get nothing returned.
child structure: child structure
Why won't it print the "postDict"?
Now I see this in my project: CFNetwork/Foundation/Security.framework turns red!
解决方案
When I re-added the missing frameworks ->
project -> build phases -> Link Binary Libraries
It worked again! Thanks for the help, though!
推荐阅读
- javascript - 在 Django 中更改文件名上传图片
- python - 训练或测试数据很少的多类图像分类问题
- java - 如何在不使用重复循环的情况下添加、计算和过滤那些低于平均值的元素
- python - 无法从 VALUE_STRING 值无反序列化日期实例,或者请求可能在 [line:1, column:131] 处缺少必填字段
- python - 使用日期时间索引按年计算行数
- tensorflow - 如何转换 tf2 模型,使其在 tflite 解释器上运行
- database - 如果条目不存在,则在链接数据库中创建新条目
- java - 如何确定复合数据类型的大小?
- java - 当我不想更新变量时,Java 正在更新它
- reactjs - Jest + @testing-library/react 在 [dom-accessibility-api] 库中的 .mjs 文件上引发错误