I am trying to return the user's state using reverseGeocodeLocation. I am using this code to pull the user's location from another view.
NSString *userState =[(PDCAppDelegate *)[UIApplication sharedApplication].delegate
getAddressFromLocation];
I am getting the following error: 'NSInvalidArgumentException', reason: '-[PDCAppDelegate getAddressFromLocation]: unrecognized selector sent to instance. The code I am using in PDCAppDelegate to return the address is below.
-(NSString *)getAddressFromLocation:(CLLocation *)location {
NSString *address;
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError
*error)
{
if(placemarks && placemarks.count > 0)
{
CLPlacemark *placemark= [placemarks objectAtIndex:0];
NSString *address = [NSString stringWithFormat:@"%@ %@,%@ %@", [placemark
subThoroughfare],[placemark thoroughfare],[placemark locality], [placemark
administrativeArea]];
NSLog(@"%@",address);
}
}];
return address;
}
Anyone know how to fix this? Thank you!