CrackerBarrelKid55
CrackerBarrelKid55

Reputation: 608

Parse GeoQuery 'withinKilometres' is not supported

Here's an interesting one:

I have a UIPickerView that contains the values "10 km", "25 km", "50 km" and "100 km". What ever value is selected will be the value [queryLocation ... withinKilometers: value here ]; is equal too. Since the value for 'withinKilometers' needs to be a double value, I have the following code to convert the X km to just X as a double value:

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

and here's the code for the query:

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");
        }
    }];

Now when I run this, I get the error [Error]: geo query within or is not supported (Code: 102, Version: 1.7.4). I'm stumped and am not sure how to fix this. Can't find anything similar to my problem either online.

EDIT: I'm starting to think maybe it's because I have connected 2 queries into 1:

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

This is to find accounts with the gender 'male' within the desired kilometres at the same time.

Upvotes: 0

Views: 191

Answers (1)

Wain
Wain

Reputation: 119031

You're right. The error geo query within or is not supported means you can't use this query with orQueryWithSubqueries. You will need to run these as 2 separate queries and then combine the result sets yourself.

Upvotes: 1

Related Questions