Parse.com PFQuery按时间排序(快速) [英] Parse.com PFQuery order by time (Swift)

查看:75
本文介绍了Parse.com PFQuery按时间排序(快速)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使所有对象都依赖于它们的创建时间,但是它总是从头开始返回,我想先获取最新信息,这是我的代码

I'm trying to get all the objects depeding on how recently they were created but its always returning from the start and i want latest first, here is my code

var query:PFQuery = PFQuery(className: "Notes")
query.orderByDescending("CreatedAt")
query.findObjectsInBackgroundWithBlock{ (objects,error) -> Void in
   if error == nil {
      for object in objects {
         self.array.addObject(object)
      }
   }
}

我尝试升序,但仍然返回相同的对象.

I tried ascending order but still returns same objects.

推荐答案

我认为问题只是"createdAt"字段以小写的'C'开头,而不是大写,因此您应该尝试:

I think the problem is just that "createdAt" field starts with a lowercase 'C', not an uppercase, so you should try:

query.orderByDescending("createdAt")

这篇关于Parse.com PFQuery按时间排序(快速)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆