Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force language in which reverse geocoding data on iOS is received?

When i call

geocoder reverseGeocodeLocation:currentLoc completionHandler:

i get all the data (city, county, ...) in a language according to locale set on iphone.

How can i force to always get this data in English?

like image 237
DixieFlatline Avatar asked Sep 13 '25 09:09

DixieFlatline


1 Answers

For future readers, the accepted answer is not true (at least not any more).

UserDefaults.standard.set(["en"], forKey: "AppleLanguages")
gc.reverseGeocodeLocation(loc) {
    print($0 ?? $1!)

    UserDefaults.standard.removeObject(forKey: "AppleLanguages")
    print(UserDefaults.standard.object(forKey: "AppleLanguages") as! [String])
}

Calling removeObject(forKey:) is important since you want to reset the returned value in UserDefaults to the system settings. Some answers make you hold the original value from calling UserDefaults.standard.object(forKey: "AppleLanguages") and set it after getting the address, but this will stop your UserDefaults from being in sync with the global Language Preferences in iOS "Settings" app.

like image 90
funct7 Avatar answered Sep 14 '25 23:09

funct7