I had some trouble with CLLocationManager callbacks
What is the best way to wait an asynchronous callback ?
Here is what i basically want to do :
- (NSString *)getCurrentCity
{
[self.locationManager startUpdatingLocation];
// Wait for coordonate in callbacks
self.geocoder = [MKReverseGeocoder alloc] initWithCoordonate:self.newCoordonate];
[self.geocoder start];
// Wait for information with MKReverse callbacks
return self.currentCity;
}
// Callbacks methods of MKReverseGeocoder and CLLocationManager
- (void)locationManager:(CLLocationManager *)manager
idUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D newCoordonate = newLocation.coordinate;
self.currentCoordonate = &newCoordonate;
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder
didFindPlacemark:(MKPlacemark *)placemark
{
self.currentCity = placemark.locality;
}
Where self.currentCity and self.newCoordonate is an attribut in my classe.
I tried some tricks like Thread and/or synchronized but i didn't managed it to dont return before all is finish.
Best regards