我的基于Parse后端的应用程序正在终止,如果没有连接到互联网,则会出现错误NSInvalidArgumentException',原因:'无法对类型进行比较查询:(null)。当有互联网连接时,一切正常,但是当我断开连接时,几秒钟后应用程序就会终止该错误。
这里是我的代码
- (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];
答案 0 :(得分:0)
请添加一些零检查代码,以确保您传递给查询的时刻不是零。我想这个问题的发生是因为PFGeoPoint类需要联网以获取当前位置,因此如果没有网络就无法正常实例化。