How do I get a list of countries in Swift ios?

后端 未结 12 1589
日久生厌
日久生厌 2021-02-05 03:29

I\'ve already seen two similar questions to mine, but the answers for those questions do not work for me. I have an old project with a list of countries manually typed out insid

12条回答
  •  既然无缘
    2021-02-05 04:21

    Swift 3 declared as a var:

    var countries: [String] {
        let myLanguageId = "en" // in which language I want to show the list
        return NSLocale.isoCountryCodes.map {
            return NSLocale(localeIdentifier: myLanguageId).localizedString(forCountryCode: $0) ?? $0
        }
    }
    

提交回复
热议问题