Problem in adding latitude and longitude value

295 Views Asked by At

when i change the latitude and longitude value of another location my app closes automatically help ?

if (1)
{
    CLLocationCoordinate2D cordi;
    cordi.latitude  =  45.574779;
    cordi.longitude = -122.685366;

    MKReverseGeocoder *coder = [[MKReverseGeocoder alloc] initWithCoordinate:cordi];
    coder.delegate = self;
    [coder start];
}
else
{
    [self performSelectorInBackground:@selector(showWeather:) withObject:@"97217"];
}
1

There are 1 best solutions below

0
On BEST ANSWER

As Twelve47 Said, you should fully implement the delegate, since both methods are not optional.

It sounds like you have only implemented the sucess method:

– reverseGeocoder:didFindPlacemark:

so when you change the location to somewhere than cant be geocoded, the fail methods gets called which causes a error.

Add this code:

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
   NSLog(@"Geocoder failed with error: %@",error);
}