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
Alternatively, you can have it in swift 4 and localized by the system language.
import Foundation
struct Country {
let name: String
let code: String
}
final class CountryHelper {
class func allCountries() -> [Country] {
var countries = [Country]()
for code in Locale.isoRegionCodes as [String] {
if let name = Locale.autoupdatingCurrent.localizedString(forRegionCode: code) {
countries.append(Country(name: name, code: code))
}
}
return countries
}
}