2
過去4天一直在嘗試獲取要調用的PFUser位置的代碼,然後將該位置拉到「位置」。從接收該「位置」,我希望根據用戶位置以升序對照片陣列進行排序。但是,用戶位置未正確填充,並且以PFUser位置nil結束。PFUser當前位置按最近的上升位置對數組進行排序
(NSArray *)caches {
PFGeoPoint *userGeoPoint = [PFUser currentUser][@"location"];
PFQuery *query = [Cache query];
[query whereKey:@"location" nearGeoPoint:userGeoPoint withinMiles:20];
query.limit = 20;
NSMutableArray *photoArray = [[query findObjects] mutableCopy];
[PFGeoPoint geoPointForCurrentLocationInBackground:^(PFGeoPoint *geoPoint,
NSError *error){
if (!error) {
[[PFUser currentUser] setObject:geoPoint forKey:@"currentLocation"];
[[PFUser currentUser] saveInBackground];
}
}];
return photoArray;
}
請格式化您的代碼以便易於閱讀。 – Nilambar