Я пытаюсь получить адрес через CLLocationManager, используя широту и долготу, но он возвращает только название штата и страны, я также хочу город, я прикрепляю свой код, может ли кто-нибудь сказать мне, как я могу изменить свой код, чтобы также получить название города. мой код
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
currentLocation = [locations objectAtIndex:0];
CLGeocoder *geocoder1 = [[CLGeocoder alloc] init];
NSLog(@"Detected Location : %f, %f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
//CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:26.9260 longitude:75.8235];
CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude];
[geocoder1 reverseGeocodeLocation:newLocation
completionHandler:^(NSArray *placemarks, NSError *error) {
if (error) {
NSLog(@"Geocode failed with error: %@", error);
return;
}
if (placemarks && placemarks.count > 0)
{
CLPlacemark *placemark = placemarks[0];
NSDictionary *addressDictionary =
placemark.addressDictionary;
NSLog(@"%@ ", addressDictionary);
NSString *address = [addressDictionary
objectForKey:(NSString *)kABPersonAddressStreetKey];
NSString *city = [addressDictionary
objectForKey:(NSString *)kABPersonAddressCityKey];
NSString *state = [addressDictionary
objectForKey:(NSString *)kABPersonAddressStateKey];
NSString *zip = [addressDictionary
objectForKey:(NSString *)kABPersonAddressZIPKey];
NSLog(@"%@ %@ %@ %@", address,city, state, zip);
}
}];
}