Subquery location using parsing (iOS)

I am currently facing an annoying issue while using an iphone app (iOS 8). Basically here's the situation: I am using Parse for my database. I created a TableViewController inheriting from PFQueryTableViewController. Now I am filling this Tableview by overwriting the queryForTable method. There I am trying to order the distance with a nested query. In fact, this is exactly the same question as the Parse Question here :

How can I order the distance? When I make this request, the results are ordered according to the Offer, but I would like to order the distance from the Restaurant (the Restaurant is a pointer in the Offer).

As you can see, below Hector's answer is to use NSSortDescriptor to sort it, but I can't figure out how. Will someone be so kind and make an example. My code looks very similar to this one:

PFGeoPoint *geopoint = [PFGeoPoint geoPointWithLocation:location];
PFQuery *position = [Restaurant createQueryForNetwork];
[position whereKey:@"location" nearGeoPoint:geopoint withinKilometers:3];

PFQuery *pfq = [Offer createQueryForNetwork];
[pfq includeKey:@"restaurant"];
[pfq whereKey:@"restaurant" matchesQuery:position];
pfq.limit = 12;

[self findAllInBackground:pfq withBlock:block];

      

I hope this is clear what I mean, otherwise let me know.

Thank!

+3


source to share