Iphone, Obtaining a List of countries in an NSArray

后端 未结 6 1849
暗喜
暗喜 2020-12-04 09:04

I have a menu that let\'s a user select a country. Exactly like that in the contacts.app country menu within the address field.

Does anyone know a simple way of get

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 09:46

    Got this one working on playgrounds

    let locale = NSLocale(localeIdentifier: "FI")
    let unsortedCountries = NSLocale.isoCountryCodes.flatMap { locale.localizedString(forCountryCode: $0) }
    let sortedCountries = unsortedCountries.sorted()
    

提交回复
热议问题