15
votes

I am calling this function once I get the addressString:

[[self geocoder] geocodeAddressString:addressString completionHandler:^(NSArray *placemarks, NSError *error) {
            if (error) {
                block(nil, nil, error);
            } else {
                CLPlacemark *placemark = [placemarks onlyObject];
                block(placemark, self.name, error);
            }
        }];

It returns placemarks as nil and error as : Error Domain=kCLErrorDomain Code=8 "The operation couldn’t be completed. (kCLErrorDomain error 8.)"

My address String is retrieved from this dictionary for placeDictionary[@"formatted_address"]:

placeDictionary = 
{
"address_components" =     (
            {
        "long_name" = "Palolem Beach";
        "short_name" = "Palolem Beach";
        types =             (
            "natural_feature",
            establishment
        );
    },
            {
        "long_name" = "South Goa";
        "short_name" = "South Goa";
        types =             (
            "administrative_area_level_2",
            political
        );
    },
            {
        "long_name" = Goa;
        "short_name" = GA;
        types =             (
            "administrative_area_level_1",
            political
        );
    },
            {
        "long_name" = India;
        "short_name" = IN;
        types =             (
            country,
            political
        );
    }
);
"adr_address" = "Palolem Beach, <span class=\"region\">Goa</span>";
"formatted_address" = "Palolem Beach, Goa";
geometry =     {
    location =         {
        lat = "15.0099648";
        lng = "74.02321859999999";
    };
    viewport =         {
        northeast =             {
            lat = "15.012671";
            lng = "74.0272093";
        };
        southwest =             {
            lat = "15.0050025";
            lng = "74.0164053";
        };
    };
};
icon = "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png";
id = b286a0f7f047e162b3cab2ab3328ce95d26bdb52;
name = "Palolem Beach";
reference = "CnRwAAAAh2ZORbEpxNv5HnZlQRY_VxKLdvAd16OusSwtBlAKibDFP6roT2idnPvm-XRgMlw3iqUsZujVFrOOns76fK9we3Uddt4b3GgcWZoSqSgoYGtbHh1l5PEL_0VAwaUcswomroA3sjd3dN8lXyBSvafrrxIQONHTpwpn6IvGtYZ12pZ5ixoUENbjRTo3dCrN3aoZTM0k5EPXAjA";
types =     (
    "natural_feature",
    establishment
);
url = "https://maps.google.com/maps/place?q=Palolem+Beach&ftid=0x3bbe4551d05b02bb:0x1e1bc67d4b0fbbf5";

}

Even if I use method:

[[self geocoder] geocodeAddressDictionary:placeDictionary completionHandler:^(NSArray *placemarks, NSError *error){

}];

It returns me the same error.

3
Just curious: Why are you calling geocodeAddressString if your dictionary already has the coordinates for the address?user467105
CLGeocoder is not reliable.. Not in India atleast.. Make sure you call google api to get address from lat long. refer my answer in the link above.Deepak Thakur

3 Answers

19
votes

You get this error in case Apple's Geocoder knows nothing about provided address.

According to Apple documentation code 8 means kCLErrorGeocodeFoundNoResult

6
votes

i think its giving you error because, geocoder is not able to find the location.

check this code , i have modified it

CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder geocodeAddressString:@"Palolem Beach, Goa, India" completionHandler:^(NSArray* placemarks, NSError* error){
    if (!error) {

        for (CLPlacemark* aPlacemark in placemarks)
        {
            NSLog(@"place--%@", [aPlacemark locality]);
            NSLog(@"lat--%f\nlong--%f",aPlacemark.location.coordinate.latitude,aPlacemark.location.coordinate.longitude);
        }
    }
    else{

        NSLog(@"error--%@",[error localizedDescription]);
    }
}];
1
votes

I have found recently that when using a US zipcode e.g. 01844 for Massachusetts it won't work if you have the proceeding 0 once I dropped the 0 and just passed 1844 it worked fine.