iphonemkreversegeocoder

MKReverseGeoCoderDelegate not being called


I am trying to use the MKReverseGeoCoder API to get a city name based of a coordinate. For some reason the delegate never gets called; any ideas why? Here is the code:

- (void)startReverseLookup
{
  [reverseCoordinateInfo initWithCoordinate:self.currentlocation.coordinate];
  [reverseCoordinateInfo setDelegate:self];
  [reverseCoordinateInfo  start];
  NSLog(@"Reverse Geocode started");
}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
     {
      NSLog(@"RC - ERROR !!!");
      }

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark    *)placemark
 {
     NSLog(@"RC lookup finished !! - Locality is:%@",placemark.locality);
 }  

I am declaring the protocol on the .h file and then I call startReverseLookup. I see the first NSLog, but after that nothing happens—it just stays there forever and the delegate never gets called for either method. Any suggestions?


Solution

  • change the following method -

    - (void)startReverseLookup
    {
        reverseCoordinateInfo = [[MKReverseGeocoder alloc] initWithCoordinate:self.currentlocation.coordinate];
        [reverseCoordinateInfo setDelegate:self];
        [reverseCoordinateInfo  start];
        NSLog(@"Reverse Geocode started");
    }