【发布时间】:2014-10-15 07:23:31
【问题描述】:
我有一个用户表,每个用户都有自己的位置(PFGEoPoint 对象)。现在我想做的是从最近到最远的位置对用户进行排序和检索。问题是一些用户没有任何位置信息(纬度、经度、地理点)。他们的 currentLocation 列是空的。这样查询就不能像我预期的那样工作。
我把下面的代码保存用户的位置来解析
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
NSLog(@"User is currently at %f, %f", geoPoint.latitude, geoPoint.longitude);
self.userLocation = geoPoint;
[[PFUser currentUser] setObject:geoPoint forKey:@"currentLocation"];
[[PFUser currentUser] saveInBackground];
}];
并将下面的代码放在我的检索查询方法上
PFGeoPoint *userGeoPoint = self.userLocation; //pass user location to PFGeoPoint
[query whereKey:@"currentLocation" nearGeoPoint:userGeoPoint]; //retrieve users from nearest to rarest
【问题讨论】:
-
有什么问题?它没有返回任何东西,是否返回不准确或不正确的结果?请在您的问题中添加对不起作用的确切说明。
-
问题是我在(解析)_users 表上有 15 个用户。有些用户有地理点,有些用户有。我想首先带来具有地理点信息的用户,并将它们从最近到最远排序。但是查询不会带来没有地理点信息的用户。
标签: ios objective-c xcode parse-platform location