我想创建一个以用户语言自动翻译的knownTimeZoneNames
列表
对于效果很好的国家/地区,我有此代码,但我无法为knowntimeZoneNames
成功完成此操作。
NSLocale *localeTwo = [NSLocale currentLocale];
NSArray *countryArray = [NSLocale ISOCountryCodes];
NSMutableArray *sortedCountryArray = [[NSMutableArray alloc] init];
for (NSString *countryCode in countryArray) {
NSString *displayNameString = [localeTwo displayNameForKey:NSLocaleCountryCode value:countryCode];
[sortedCountryArray addObject:displayNameString];
NSLog(@"NSDisplayNameString : %@", displayNameString);
}
[sortedCountryArray sortUsingSelector:@selector(localizedCompare:)];
[sortedCountryArray sortUsingSelector:@selector(localizedCompare:)];
答案 0 :(得分:0)
[NSTimeZone knownTimeZoneNames]
制造了这个东西。尝试:
NSArray * knownTimeZoneArray = [NSTimeZone knownTimeZoneNames];
NSLog(@"knownTimeZoneArray = %@", knownTimeZoneArray);