CLPlacemark.locality, value changes if the device language is different

Usually, it is not a good practice to mess with user locales. If the device language is set to Chinese is because the user want to read Chinese characters so, why do you want to show him in English when he already told you that he want Chinese?

Anyway, if for any reason you need to force english, you can trick the geoCoder which uses the standardUserDefaults first language so you can do something like this just before calling the geoCoder method:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", nil] forKey:@"AppleLanguages"];

This way, geoCoder will give you all the information in english.

However, this will change the user preferences so it is a best approach to give them back to where they were:

NSMutableArray *userDefaultLanguages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", nil] forKey:@"AppleLanguages"];

[self.geoCoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray* placemarks, NSError* error){
       MKPlacemark *placemarker = [placemarks objectAtIndex:0];
       NSLog(@"%@",placemarker.locality);
   }];

[[NSUserDefaults standardUserDefaults] setObject:userDefaultLanguages forKey:@"AppleLanguages"];

As I said, you should really think why you need this, but if you really need this, that would work.


I found a nice solution

NSString *country = placemark.ISOcountryCode;

This will return the exact country no matter your locale is. For example country will be @"US" instead of @"United States"

Tags:

Ios

Clgeocoder