I am trying to use reverse geocode but the function is not executing and not really sure why..
Here I attached my code. Thank you for your help
//-- reverse geocode, converting from point to address
- (BNRMapPoint *)geocodeLocation:(CLLocation *)location title:(NSString *)title
{
if(!geocoder)
{
geocoder = [[CLGeocoder alloc] init];
}
__block BNRMapPoint * annotation;
[self.geocoder reverseGeocodeLocation:location completionHandler:
^(NSArray * placeMarks, NSError * errors)
{
NSLog(@"in block code");
if([placeMarks count] > 0)
{
NSLog(@"%@", [placeMarks objectAtIndex:0]);
annotation = [[BNRMapPoint alloc] initWithCoordinate:location.coordinate title:title
placeMark:[placeMarks objectAtIndex:0]];
NSLog(@"%@", annotation.placeMark.name);
}
else
{
NSLog(@"failed!!");
}
}];
return annotation;
}
it is not printing anything at console.. so I figured it’s not entering the block code.
But I am really confused why it’s not entering. Thank you again for your help
I seem to remember having a problem with
NSLogin a block passed toreverseGeocodeLocation. The Geocoder executes on a separate thread, as will the block, I expect. (I’m sure someone will correct me if I’m wrong about that). In my case, I think `UIAlertView worked even in the block code, so you might try that …I reviewed your code against an app I have that’s working with
reverseGeocodeLocationand I don’t see a problem with your code. The only difference is that I do a check forif (![geocoder isGeocoding])...before I do the reverseGeocode. That’s just to keep geoCoder calls from stacking up, which may not be possible in your app depending on how your code gets called.