1

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

  1. At times it works like charm
  2. At times it waits and shows the result after long time interval
  3. 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.)

4
  • It is a web service and has rate and other limitations, see the Apple documentation. On error check and print the error to see why. Add the error information to the question. Also show your code, especially the completionHandler code.
    – zaph
    Commented Jun 18, 2015 at 12:41
  • Yes Zaph, Just saw the documentation. I think there is no option rather than waiting for it to get the result. Is there is any other solution to get it.
    – JiteshW
    Commented Jun 18, 2015 at 12:51
  • I am trying to catch the error. but its not appearing now. Once I came across it, I will share it. :)
    – JiteshW
    Commented Jun 18, 2015 at 13:05
  • I received the error and have updated the same in the question part. When I checked the error code 8 its equal to kCLErrorGeocodeFoundNoResult
    – JiteshW
    Commented Jun 18, 2015 at 13:38

1 Answer 1

4

Here is why you get results sometimes, others not. Straight from Apple's Docs on Geocoding

Applications should be conscious of how they use geocoding. Geocoding requests are rate-limited for each app, so making too many requests in a short period of time may cause some of the requests to fail. (When the maximum rate is exceeded, the geocoder returns an error object with the value kCLErrorNetwork to the associated completion handler.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.