所以我在 parse.com 上有一堆对象。类名为“MainInfo”,地理点位于名为 geoPoint 的列中。
我通过将以下内容添加到我的 .h 文件来获取用户位置:
@property (nonatomic, strong) PFGeoPoint *userLocation;
然后将以下内容添加到 viewDidLoad:
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint, NSError *error) {
if (!error) {
self.userLocation = geoPoint;
[self loadObjects];
}
}];
并执行滚动 queryForTable:
- (PFQuery *)queryForTable
{
// User's location
PFGeoPoint *userGeoPoint = self.userLocation;
// Create a query for places
PFQuery *query = [PFQuery queryWithClassName:@"MainInfo"];
// Interested in locations near user.
[query whereKey:@"geoPoint" nearGeoPoint:userGeoPoint];
// Limit what could be a lot of points.
query.limit = 10;
// Final list of objects
_placesObjects = [query findObjects];
return query;
}
Xcode给了我错误*** setObjectForKey: object cannot be nil (key: $nearSphere)
我不知道我做错了什么,据我所知它应该可以工作。
我与解析文档一起工作让我走到了这一步。这是一个链接