Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
I was wondering if there's a way to get a default country list from the system in Cocoa. I figure the system has a default country list, from all the options in the OS where you can choose a country, whether it's for an address, or whatever. Does this list exist, and is there a way to access it?
 
I don't think so. I looked through it, but couldn't find what I need. Let me try to explain it better. I'm looking to create a popUp in my program that will allow the user to select any country on earth. Now, instead of entering all these manually, I'd like to be able to populate the popUp automatically. Any idea on how to do that?
 
I suggest you look again. Something like this should work

Code:
NSMutableArray *countryNamesArray = [NSMutableArray array];
NSLocale *current = [NSLocale currentLocale];
for (NSString *countryCode in [NSLocale ISOCountryCodes])
{
[countryNamesArray addObject:[current displayNameForKey:NSLocaleCountryCode value:countryCode]];
}

Note I've not actually used this: just typed it straight into here having read the documentation I suggested you read.
 
Lots of Stuff

There's lots of stuff in Cocoa, thus there's lots of stuff in the documentation.

To program in Cocoa, you need to have:
1. The ability to program; and
2. The ability to read and understand Cocoa documentation.

Spend a couple of hours or days just wandering through NSString and reading the method documentation. Do that so that you understand NSString, but also so that you understand how the documentation is structured.

Then when someone suggests you look in NSLocale or NSWhatever, you can extract the data that's in there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.