Skip to content

Instantly share code, notes, and snippets.

@Matsue
Created September 3, 2014 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Matsue/0a5ba03322e2678bb77a to your computer and use it in GitHub Desktop.
Save Matsue/0a5ba03322e2678bb77a to your computer and use it in GitHub Desktop.
Swiftで国名コードの変換 ref: http://qiita.com/waytoa/items/514cdf795f092e900bba
NSLocale.ISOCountryCodes() // ["AD", "AE", "AF", "AG", "AI",...]
// 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