不支持Parse GeoQuery'inkilometres'

时间:2015-07-01 06:55:41

标签: ios parse-platform geolocation

这是一个有趣的:

我有一个UIPickerView,其中包含“10 km”,“25 km”,“50 km”和“100 km”的值。选择的值是[queryLocation ... withinKilometers: ];也是平等的。 由于'withinKilometers'的值需要是一个double值,我有以下代码将X km转换为X作为double值:

    if ([self.selectedData isEqualToString:@"10 km"]) {
    self.selectedDataConverted = @"10"; 
    self.stringToDouble = [self.selectedDataConverted doubleValue];
    NSLog(@"Double Value: %f", self.stringToDouble);
}
... and so on...

这是查询的代码:

PFQuery *queryLocation = [PFUser query];
[queryLocation whereKey:@"location" nearGeoPoint:self.userLocation withinKilometers:self.stringToDouble];

if (!error) {
            NSLog(@"Great Success");
            //Do the stuff here
        }
        else {
            NSLog(@"Error");
        }
    }];

现在,当我运行此操作时,我收到错误[Error]: geo query within or is not supported (Code: 102, Version: 1.7.4)。我很难过,我不知道如何解决这个问题。在网上找不到与我的问题类似的东西。

编辑:我开始认为可能是因为我已将2个查询连接到1:

    PFQuery *finalQuery = [PFQuery orQueryWithSubqueries:@[queryMale, queryLocation]];
    [finalQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
            NSLog(@"Great Success");
        }
        else {
            NSLog(@"Error");
        }
    }];

这是为了在同一时间内找到所需公里内性别为“男性”的帐户。

1 个答案:

答案 0 :(得分:1)

你是对的。错误geo query within or is not supported表示您无法将此查询与orQueryWithSubqueries一起使用。您需要将它们作为2个单独的查询运行,然后自己组合结果集。