- (NSString *)countryNameByCode:(NSString*)countryCode { NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}]; NSString *countryName = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:identifier]; return countryName; }
countryName null. Warum?xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier return nil
Es Problem: http://stackoverflow.com/questions/26603766/swift-nslocale-simulator-ios-8 –
Dieses Problem nur Simulator. Ich habe es heute auf einem Gerät getestet, ich bekomme den richtigen Ländernamen. –
lief gerade in den Simulatoren auf dieses Problem - ich bevölkerte eine Tabellenansicht mit einer Liste aller Länder und im Simulator stürzte es gerade ab, weil displayNameForKey null zurückgab. Ich habe es auf allen Simulatoren mit 8.1 ausprobiert und alle stürzen ab. iPhone4 und iPhone 5 Simulatoren mit iOS 7.1 laufen gut. Mein Code läuft auch gut auf physischen Geräten iPhone4s und iPhone5 mit 8.1 installiert, so dass ich denke, es ist nur ein Xcode Bug. Lösung - bis Apple Fix, Test auf dem Gerät - das ist ein bugger, wie ich nicht 6 und 6 plus zur Hand :( – SimonTheDiver