【发布时间】:2018-05-25 16:00:34
【问题描述】:
我在聊天中使用 Firebase。
我想获取特定时间的所有消息。 但我只收到来自 Firebase 的一条消息。
这是我的代码:
[[[_conversationDBRef queryOrderedByChild:@"time"] queryStartingAtValue:@(time)] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
for (FIRDataSnapshot* child in snapshot.children) {
NSDictionary* msgData = child.value;
NSLog(@"msgData: %@", msgData);
}
}];
查询:
(lldb) po _conversationDBRef
https://xxxxx-xxxxxx.firebaseio.com/Strike-Fighter/messages/4_5
(lldb) po [[_conversationDBRef queryOrderedByChild:@"time"] queryStartingAtValue:@(time)]
(/Strike-Fighter/messages/4_5 {
i = time;
sp = "548914514.2122542";
})
【问题讨论】:
-
如果您欣赏一些建议,请在时间戳中使用整数值而不是浮点数。
标签: ios objective-c firebase firebase-realtime-database