简体   繁体   中英

Parse.com relation object specify order

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.

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) {

}];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM