Created
September 3, 2014 22:24
-
-
Save Matsue/0a5ba03322e2678bb77a to your computer and use it in GitHub Desktop.
Swiftで国名コードの変換 ref: http://qiita.com/waytoa/items/514cdf795f092e900bba
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
NSLocale.ISOCountryCodes() // ["AD", "AE", "AF", "AG", "AI",...] |
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
// Sample ISO 3166-1 Dictionary | |
let ISOCountryCodes = [250: "FR"] | |
// Sample input value | |
let countryNumericCode = 250 | |
// Convert to country name | |
let countryCode = ISOCountryCodes[countryNumericCode] | |
let countryName = NSLocale.currentLocale().displayNameForKey(NSLocaleCountryCode, value: countryCode) // "France" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment