按距离排序PFQuery

时间:2015-04-21 20:38:13

标签: ios iphone parse-platform sdk

我正在使用Parse并尝试运行一个查询,其中我的对象按照距离排序并按一定比例的降序排序:

    PFQuery *moreGuysQuery = [PFQuery queryWithClassName:self.parseClassName];
    [moreGuysQuery whereKey:@"Location" nearGeoPoint:self.currentLocation];
    [moreGuysQuery orderByDescending:@"Ratio"];

但是,我发现这个比例正在占据优势,并且没有考虑到这个位置。我希望这个位置也能占据优势。

这可能吗?

1 个答案:

答案 0 :(得分:0)

通过制作数组

来解决这个问题
    PFQuery *moreGuysQuery = [PFQuery queryWithClassName:self.parseClassName];

    NSSortDescriptor *sortByLocation = [[NSSortDescriptor alloc] initWithKey:QuoVenueLocation ascending:NO selector:@selector(localizedCompare:)];
    NSSortDescriptor *sortByRatio = [[NSSortDescriptor alloc] initWithKey:QuoVenueStatsCrowdRatio ascending:NO selector:@selector(localizedCompare:)];
    [moreGuysQuery orderBySortDescriptors:[NSArray arrayWithObjects:sortByLocation, sortByRatio, nil]];
相关问题