Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 按特定字段截断firebase项_Ios_Swift_Firebase_Firebase Realtime Database - Fatal编程技术网

Ios 按特定字段截断firebase项

Ios 按特定字段截断firebase项,ios,swift,firebase,firebase-realtime-database,Ios,Swift,Firebase,Firebase Realtime Database,我是iOS和Swift的初学者,似乎无法截断数据库注释列表,只显示当前活动的注释 注释有一个endtimestamp字段,它是一个整数,例如:1507522353 以下是获取10多条注释的代码区域: commentsRef.observe(.childAdded, with: { (snapshot) -> Void in self.comments.append(snapshot) self.tableView.insertRows(at: [IndexPath(row: sel

我是iOS和Swift的初学者,似乎无法截断数据库注释列表,只显示当前活动的注释

注释有一个endtimestamp字段,它是一个整数,例如:1507522353

以下是获取10多条注释的代码区域:

commentsRef.observe(.childAdded, with: { (snapshot) -> Void in
  self.comments.append(snapshot)
  self.tableView.insertRows(at: [IndexPath(row: self.comments.count-1, section: self.kSectionComments)], with: UITableViewRowAnimation.automatic)
})
我只想附加(并显示)endtimestamp
谢谢

您可以使用
查询绑定(atValue:)
实现这一点,其中的值是当前时间戳(以毫秒为单位)减去一。查询按
endtimestamp
排序,以便为结束于值查询指定子键

let now = Date().timeIntervalSince1970 * 1000.0
let query = commentsRef
    .queryOrdered(byChild: "endtimestamp")
    .queryEnding(atValue: now - 1)

query.observe(.childAdded, ...

您的问题有点不清楚,请补充更多信息。您的期望是什么?您尝试了什么?当前实施的结果是什么?