0

my Parse backends based aplication, is terminating, if not cooencted to the internet, with the error NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: (null). When there is an internet connection, all is working fine, but when i disconect, then after few seconds the app is terminating with that error.

Here us my code

- (void)queryParseMethod {
NSLog(@"start query");


PFQuery *query = [UserParseHelper query];
[query whereKey:@"username" notEqualTo:self.mainUser.username];
PFGeoPoint *userGeoPoint = self.mainUser.geoPoint;
[query whereKey:@"geoPoint" nearGeoPoint:userGeoPoint];

if (self.segmentedControl.selectedSegmentIndex == 0) {
    [query whereKey:@"isMale" equalTo:@"true"];

}
if (self.segmentedControl.selectedSegmentIndex== 1) {
   [query whereKey:@"isMale" equalTo:@"false"];

}


PFUser *chekUser = [PFUser currentUser];
NSString *vip = chekUser[@"membervip"];
if ([vip isEqualToString:@"vip"]) {

    NSLog(@"Unlim - vip member");
    self.upgradeVip.hidden = YES;
    self.upgradedVip.hidden = NO;

} else{

    NSLog(@"No Unlim - no vip member");
 //   query.limit = limitQueruNoVipUser;
    self.upgradeVip.hidden = NO;
    self.upgradedVip.hidden = YES;

}

[query whereKey:@"geoPoint" nearGeoPoint:self.mainUser.geoPoint withinKilometers:self.mainUser.distance.doubleValue];
rici
  • 234,347
  • 28
  • 237
  • 341
MSinga Pro
  • 31
  • 6

1 Answers1

0

Please add some nil checking code to make sure the instants you pass to query is not nil. I guess the problem happened because of the PFGeoPoint class need networking to get current location so can not instantiate properly without networking.

MatthewLuiHK
  • 691
  • 4
  • 10
  • i was thinking on that too, but what happen if i cache PFGeoPoint result? or there is a way to make app to warn that there is no internet connection and not to terminate suddenly – MSinga Pro Sep 14 '15 at 03:00
  • Sorry for my late reply. As I remember, PFGeoPoint can be instantiated with core location's location. So if you've check the network service seems to be disable, you can call the core location service and get the current location as an alternative. After you get the CLLocation or some what, you can manually instantiate a PFGeoPoint object and do the rest. But actually, you can't fetch query when there are not network, so why would you still like to get the GeoPoint in this case? – MatthewLuiHK Oct 01 '15 at 05:22