Parse iOS: NSInvalidArgumentException', 原因: '无法对类型进行比较查询: (null)

Parse iOS: NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: (null)

我的基于 Parse 后端的应用程序正在终止,如果没有连接到互联网,错误 NSInvalidArgumentException',原因:'无法对类型进行比较查询:(空)。当有互联网连接时,一切正常,但当我断开连接时,几秒钟后应用程序因该错误而终止。

这是我的代码

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

请添加一些 nil 检查代码以确保您传递给查询的时刻不为 nil。我想问题的发生是因为 PFGeoPoint class 需要联网才能获取当前位置,因此在没有联网的情况下无法正确实例化。