I have a menu that let\'s a user select a country. Exactly like that in the contacts.app country menu within the address field.
Does anyone know a simple way of get
You might want to define locale..
and there is too much autoreleased memory, which might be critical, ye never know. so create autoreleased pool inside the for loop as well.
I've this:
NSMutableArray * countriesArray = [[NSMutableArray alloc] init];
NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier: @"en_US"] autorelease];
NSArray *countryArray = [NSLocale ISOCountryCodes];
for (NSString *countryCode in countryArray)
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *displayNameString = [locale displayNameForKey:NSLocaleCountryCode value:countryCode];
[countriesArray addObject:displayNameString];
[pool release];
}
[countriesArray sortUsingSelector:@selector(compare:)];