作者:清-新花曼的日子 | 来源:互联网 | 2023-05-18 06:37
IhavesavedmydatausingchildByAutoIdsothatitisorderedchronologicallyinFirebase.WhenIq
I have saved my data using childByAutoId
so that it is ordered chronologically in Firebase. When I query using the query below, and then I print the snapshot.value
it prints in the orders as I expected --ordered chronologically--, but when I try to enumerate over snapshot.value
, and when I try to get the keys with [snap.value allkeys]
, they are no longer ordered chronologically. I have tried using [self.refMyOrder queryOrderedByKey]
and [self.refMyOrders queryOrderedByChild:@"timestamp"
for which I have a child timestamp
that is a data-type long
of the Epoch time. But still, it is not maintaining the desired order.
我使用childByAutoId保存了我的数据,因此它在Firebase中按时间顺序排序。当我使用下面的查询查询,然后我打印snapshot.value它按照我预期的顺序打印 - 按时间顺序排序 - 但是当我尝试枚举snapshot.value时,以及当我尝试获取密钥时使用[snap.value allkeys],它们不再按时间顺序排序。我已经尝试使用[self.refMyOrder queryOrderedByKey]和[self.refMyOrders queryOrderedByChild:@“timestamp”,我的子时间戳是Epoch时间的数据类型。但是,它仍然没有维持所需的顺序。
I understand that the underlying data structure of an NSDictionary is not an ordered data structure.
据我所知,NSDictionary的底层数据结构不是有序的数据结构。
What am I doing wrong?
我究竟做错了什么?
[self.refMyOrders observeSingleEventOfType:FEventTypeValue withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"snapshot.value = %@", snapshot.value);
NSLog(@"all keys = %@", [snapshot.value allKeys]);
}];
1 个解决方案