Swift - Liste der Länder abrufen

Wie kann ich ein Array mit allen Ländernamen in Swift erhalten? Ich habe versucht, den Code, den ich in Objective-C hatte, zu konvertieren.

if (!pickerCountriesIsShown) {
    NSMutableArray *countries = [NSMutableArray arrayWithCapacity: [[NSLocale ISOCountryCodes] count]];

    for (NSString *countryCode in [NSLocale ISOCountryCodes])
    {
        NSString *identifier = [NSLocale localeIdentifierFromComponents: [NSDictionary dictionaryWithObject: countryCode forKey: NSLocaleCountryCode]];
        NSString *country = [[NSLocale currentLocale] displayNameForKey: NSLocaleIdentifier value: identifier];
        [countries addObject: country];
    }

Und in Swift kann ich von hier nicht passieren:

        if (!countriesPickerShown) {
        var countries: NSMutableArray = NSMutableArray()
        countries = NSMutableArray.arrayWithCapacity((NSLocale.ISOCountryCodes).count) // Here gives the Error. It marks NSLocale.ISOCountryCodes and .count

Weiß jemand von euch davon?

Vielen Dank

Antworten auf die Frage(3)

Ihre Antwort auf die Frage