ios - Firebase 没有收到键值 Swift

标签 ios swift firebase swift3 firebase-realtime-database

出于某种原因,我无法接受我 child 的值(value)观,我也不明白为什么。每个值都表示为 double 值。

没有过去

if let snapDict = snap.value as? [Double:AnyObject]{

enter image description here

func recieveChartValues() {

    //Firebase Initialization
    var ref: FIRDatabaseReference!
    ref = FIRDatabase.database().reference()

    ref.child("general_room_index").observeSingleEvent(of: .value, with: {(snap) in


        if let snapDict = snap.value as? [Double:AnyObject]{


            for each in snapDict{

                print("key ", each.key)
                self.values.append(each.key)
            }
        }
    })

}//retrive values func

最佳答案

If all of the keys are integers, and more than half of the keys between 0 and the maximum key in the object have non-empty values, then Firebase will render it as an array.

所以我相信您总是使用一些字符串而不是 Int 作为键,因为顺序方式的键通常会转换为数组,因为 firebase 认为它会自动递增 ...

更多信息。检查this answer

关于ios - Firebase 没有收到键值 Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42943224/

相关文章:

ios - 如何从自定义单元格类更改数据源

iOS ASIHTTPRequest [请求临时文件下载路径];会自动下载文件并删除吗?

ios - 如何在编辑代码文件时查看 Storyboard 发生的变化,反之亦然?

ios - 在后台快速定期检查healthkit数据

node.js - 是否可以通过对位于该函数的单独 Firebase 项目中的 Firestore 的更改来触发 Firebase 函数?

javascript - 如何在 React-Native 中从 firebase 返回一组 child

ios - Swift:解释 NSURLSession.sharedSession().dataTaskWithURL 的语法语法

ios - Swift 中的自定义/通用工具栏

ios - 显示选定单元格的 UICollectionView

android - 当 Android 中数组中的值超过 1 个时,Firestore whereArrayContains 不起作用