I am trying to retrieve the timestamp of the last child in chatRef
. It works fine when persistence is disabled. When it is enabled it returns an object in between instead of the last one.
How is this possible?
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
}
}
})
}