我正在尝试检索chatRef
中最后一个孩子的时间戳。禁用持久性时,它工作正常。启用它后,它将返回一个对象而不是最后一个对象。
这怎么可能?
self.chatRef.queryOrderedByChild("timestamp").queryLimitedToLast(1).observeSingleEventOfType(.Value, withBlock: { (snapshot) -> Void in
for child in snapshot.children {
let childSnapshot = snapshot.childSnapshotForPath(child.key!!)
if let object = childSnapshot.value as? [String: AnyObject] {
var timestamp = (object["timestamp"] as? NSNumber)!.longLongValue
timestampQueryValue = NSNumber(longLong: timestamp)
print("timestamp of childSnapshot: \(timestampQueryValue)")
// actually prints the timestamp of an older object when persistence is enabled
}
}
})
}