धन्यवाद चक।
यदि कोई दिलचस्पी है या एक ही समाधान ढूंढना चाहता है तो यहां देशों के एक क्रमबद्ध सरणी के लिए मेरा कोड है।
ऑब्जेक्टिव-सी:
NSLocale *locale = [NSLocale currentLocale];
NSArray *countryArray = [NSLocale ISOCountryCodes];
NSMutableArray *sortedCountryArray = [[NSMutableArray alloc] init];
for (NSString *countryCode in countryArray) {
NSString *displayNameString = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];
[sortedCountryArray addObject:displayNameString];
}
[sortedCountryArray sortUsingSelector:@selector(localizedCompare:)];
स्विफ्ट:
let locale = NSLocale.currentLocale()
let countryArray = NSLocale.ISOCountryCodes()
var unsortedCountryArray:[String] = []
for countryCode in countryArray {
let displayNameString = locale.displayNameForKey(NSLocaleCountryCode, value: countryCode)
if displayNameString != nil {
unsortedCountryArray.append(displayNameString!)
}
}
let sortedCountryArray = sorted(unsortedCountryArray, <)
स्विफ्ट 3
let locale = NSLocale.current
let unsortedCountries = NSLocale.isoCountryCodes.map { locale.localizedString(forRegionCode: $0)! }
let sortedCountries = unsortedCountries.sorted()
स्रोत
2009-02-02 11:09:46
इस पर काम कर रहे: - http://stackoverflow.com/प्रश्न/26613011/xcode-6-1-ios-8-1-nslocale-displaynameforkey-nslocaleidentifier-return-nil –