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
Update to vedo27's answer but in Swift 5:
let countries : [String] = NSLocale.isoCountryCodes.map { (code:String) -> String in
let id = NSLocale.localeIdentifier(fromComponents: [NSLocale.Key.countryCode.rawValue: code])
return NSLocale(localeIdentifier: "en_US").displayName(forKey: NSLocale.Key.identifier, value: id) ?? "Country not found for code: \(code)"
}
Also for having a sorted array for countries in Alphabetical order add this below in your order after fetching countries list
let sortedcountries = countries.sorted { $0 < $1 }