1

I am using the following code to get the user's city and country in Iphone.

CLLocation *location = // Some location


 [[[CLGeocoder alloc] init] reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {}];

It works but the problem is that it returns the values in a specified language. For example, if the user's current country is UAE and City Dubai then it gives me values as دبي and لإمارات . I want to get these values in English, for example, Dubai and United Arab Emirates.

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322
  • See the answer: http://stackoverflow.com/questions/1382900/how-to-retrieve-users-current-city-name – Apurv Feb 04 '13 at 08:51
  • possible duplicate of [How to force language in which reverse geocoding data on iOS is received?](http://stackoverflow.com/questions/12174606/how-to-force-language-in-which-reverse-geocoding-data-on-ios-is-received) – Matthias Bauch Feb 04 '13 at 08:52
  • check out NSLocalisedString http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-localization-with-nslocalizedstring/ – Rachel Gallen Feb 04 '13 at 08:53
  • @RachelGallen NSLocalizedString is not helpful when dealing with arbitrary strings. NSLocalizedString is great for localizing your own strings. It can't be used for localizing names for all (!) the places in all (!) languages in the world back to english. – Matthias Bauch Feb 04 '13 at 09:05
  • @MatthiasBauch, MKReverseGeocoder is deprecated and it's replacement is CLGeocoder which is giving me localized values then how this post duplicate. – Imran Qadir Baksh - Baloch Feb 04 '13 at 09:41

1 Answers1

3

use this code to get detail.

#define REVERSE_GEO_CODING_URL @"https://maps.googleapis.com/maps/api/geocode/json?"

    NSString *urlStr = [NSString stringWithFormat:@"%@latlng=%@,%@&sensor=true",REVERSE_GEO_CODING_URL,latitude,longitude];

        DLog(@"%@",urlStr);
        NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
        NSString *json = [BKAPIClient handleConnection:request];
        [request release];
        if (json)
            return (NSMutableDictionary *)[json JSONValue];

I have tested this using saudi arabia's latlong and it return english address in return.

see this link its gives address of somewhere in Saudi arabia .

Dilip Manek
  • 9,095
  • 5
  • 44
  • 56