내 앱을 사용하는 가장 가까운 15 명의 사용자 목록을 가져와야합니다. 현재 사용자의 현재 위치는 다음과 같이 저장됩니다Parse.com 근처에 사용자가 있습니다
PFGeoPoint *currentLocation = [PFGeoPoint geoPointWithLocation:newLocation];
PFUser *currentUser = [PFUser currentUser];
[currentUser setObject:currentLocation forKey:@"location"];
[currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error)
{
NSLog(@"Saved Users Location");
}
}];
지금 난과 같이 근처 PFQuery를 통해 사용자를 검색하고 싶습니다 :
- (NSArray *)findUsersNearby:(CLLocation *)location
{
PFGeoPoint *currentLocation = [PFGeoPoint geoPointWithLocation:location];
PFQuery *locationQuery = [PFQuery queryWithClassName:@"User"];
[locationQuery whereKey:@"location" nearGeoPoint:currentLocation withinKilometers:1.0];
locationQuery.limit = 15;
NSArray *nearbyUsers = [locationQuery findObjects];
return nearbyUsers;
}
불행하게도이 작동하지 않습니다. 내 배열에는 항목이없는 것 같습니다. 누군가가 나를 위해 일들을 정리할 수 있습니까? 어떻게 쿼리를 올바르게 사용합니까?
환호, 데이비드
는(도에 게시 : https://www.parse.com/questions/pfquery-to-retrieve-users-nearby)
감사합니다. 매우 감사;) – dehlen