出于某种原因,我无法接受我 child 的值(value)观,我也不明白为什么。每个值都表示为 double 值。
没有过去
if let snapDict = snap.value as? [Double:AnyObject]{
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/