Created
February 29, 2016 19:15
-
-
Save jemmons/cad7709ef98cfaea2a0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Doesn't work. */ | |
NSLocale.currentLocale().displayNameForKey(NSLocaleCountryCode, value: "DE") | |
//> nil | |
/* Does work. */ | |
NSLocale(localeIdentifier: "en_US").displayNameForKey(NSLocaleCountryCode, value: "DE") | |
//> "Germany" | |
/* Just to make sure my currentLocale isn't nil or something daft */ | |
let identifier = NSLocale.currentLocale().localeIdentifier | |
//> "en_US" | |
/* Ensure the same locale as currentLocale */ | |
NSLocale(localeIdentifier: identifier).displayNameForKey(NSLocaleCountryCode, value: "DE") | |
//> "Germany |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment