Orderby定位带解析的嵌套查询(iOS)

时间:2014-10-15 05:38:12

标签: ios iphone parse-platform nested nssortdescriptor

我在使用iphone应用程序(iOS 8)时遇到了一个恼人的问题。 基本上就是这种情况: 我使用Parse作为我的数据库。我创建了一个继承自PFQueryTableViewController的TableViewController。 现在我通过覆盖queryForTable方法来填充这个Tableview。在那里,我尝试使用嵌套查询按距离排序。这实际上就像这里Parse Question完全相同的问题:

  

我如何订购距离?当我这样查询时,结果是按优惠订购的,但我想按餐厅的距离订购(餐厅是优惠中的指针)。

正如你所看到的,Hector回答使用NSSortDescriptor对它进行排序,但我无法弄清楚如何做到这一点。有人会这么善良并做出榜样。我的代码与这个代码非常相似:

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];

我希望我的意思很清楚,否则请告诉我。

谢谢!

0 个答案:

没有答案