Ankit
Ankit

Reputation: 280

Parse.com PFQuery order by time (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.

Upvotes: 2

Views: 2180

Answers (1)

Dániel Nagy
Dániel Nagy

Reputation: 12015

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

query.orderByDescending("createdAt")

Upvotes: 5

Related Questions