Reputation: 161
How do I retrieve the order of a Parse relation as I specified it? For example if I have a list of _User objects that I added to a PF relation in a certain order, how can I get an array back with these PF objects in the order that I specified? Should I instead just make an array and put PF objects in that? Or should I make an array and simply put the object ids in it so that I can order it?
Any advice would be appreciated...thanks.
Upvotes: 1
Views: 508
Reputation: 1269
Using the query property of a relation you can order the query, and fetch the results. If you want it sorted by the order in which you added them to the relation I would create a new column for that relation and increment that column as you add the object.s
PFQuery *query = object.relation.query;
[query orderByAscending:@"column_to_order_by"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
}];
Upvotes: 1