本文介绍了Parse.com PFQuery 按时间排序(Swift)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图根据最近创建的对象获取所有对象,但它总是从一开始就返回,我想要最新的,这是我的代码
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 按时间排序(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!