当使用QuickBlox iOS框架检索自定义对象时,是否有一种方法可以使结果按“创建时间”字段从最新到最早的排序?
NSMutableDictionary *getRequestFavs = [NSMutableDictionary dictionary];
[getRequest setObject:[NSString stringWithFormat:@"%lu", (unsigned long)currentUser.ID] forKey:@"favoriteID"];
// not sure what to do here...
[getRequest setObject:@"???" forKey:@"sort_desc"];
[QBRequest objectsWithClassName:@"Favorites" extendedRequest:getRequest successBlock:^(QBResponse *response, NSArray *objects, QBResponsePage *page) {
} errorBlock:^(QBResponse *response) {
}];
最佳答案
对于遇到此问题的任何人,我都设法通过使用对象的ID字段进行排序来解决此问题。它已建立索引,并且比created_at字段快得多。
[getRequest setObject:@"_id" forKey:@"sort_desc"];