I am facing some weird issue with reverseGeocodeLocation
. This is what I do.
I push from one view controller
to another. After view appears, I calls for current location. In didUpdateLocations delegate
when I receives current location, I call for reverseGeocodeLocation
to get the place mark values.
Problem
- At times it works like charm
- At times it waits and shows the result after long time interval
- At times I don't get any result.
Below is my code to get reverse geo location
- (void)getReverseLocation
{
__block CLPlacemark* placemark;
CLGeocoder* geocoder = [CLGeocoder new];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
{
if(error)
NSLog(@">>>>>>>> Error in reverseGeoLocation - %@", [error localizedDescription]);
if (error == nil && [placemarks count] > 0)
{
placemark = [placemarks lastObject];
completionBlock(placemark);
}
}];
}
I am not sure why its behaving like this. I am at same location and internet connectivity is good.
Is this because of threads? I have tried this on main thread too. But same problem.
Edit : I got this error, After some tries
Error in reverseGeoCodeLocation - The operation couldn’t be completed. (kCLErrorDomain error 8.)
Here is why you get results sometimes, others not. Straight from Apple's Docs on Geocoding