0

I am calling the following method, but randomly the placemarks NSArray is coming back nil. I have a break point set if location is nil and I have validated that the location is a valid object even when placemarks comes back nil. I can't figure out what is going wrong? Any suggestions?

-(void)geocodeRequest:(CLLocation *)location {

CLGeocoder
* gc = [[CLGeocoder alloc] init];

if(nil == location){
    DLog(@"");
}

[gc reverseGeocodeLocation:(CLLocation *)(location) completionHandler:^(NSArray *placemarks, NSError *error) {

    //Get address
    CLPlacemark *placemark = [placemarks objectAtIndex:0];  <-- nil sometimes
.....
.....

 }];
}// end geocodeRequest method

// UPDATE //

It is erroring out with!!!

Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)"
jdog
  • 10,351
  • 29
  • 90
  • 165
  • Have you checked the `error` object? What does it say? –  Jun 30 '14 at 20:14
  • no. dumb of me. checking now. – jdog Jun 30 '14 at 20:58
  • Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)" – jdog Jun 30 '14 at 21:02
  • See http://stackoverflow.com/questions/17867422/kclerrordomain-error-2-after-geocoding-repeatedly-with-clgeocoder, http://stackoverflow.com/questions/13888076/clgeocoder-reversegeocodelocation-kclerrordomain-error-2. –  Jul 15 '14 at 23:32

1 Answers1

0

The issue is this error which is Apple not returning a result as I have made to many requests to their API.

"Error Domain=kCLErrorDomain Code=2 "The operation couldn’t be completed. (kCLErrorDomain error 2.)"

I rewrote part of the app so it doesn't ask Apples API to reverse geocode so often. I have also hooked up to Googles API so if Apple returns this error I ask Google to do the reverse geocode.

jdog
  • 10,351
  • 29
  • 90
  • 165