small medium large xlarge

Back to: All Forums  Using Map Kit
16 Jul 2010, 14:42
Ryan (2 posts)

Hi everyone,

I noticed that when a European iPhone user with a Region Format (in iPhone settings>General>International>Region Format) of Germany (or a few other select countries) runs the application the annotations do not appear. I have narrowed this down to being a problem with the way these countries format their numbers.

In the US, we use the decimal point:

18.5909 -68.9919

However in some countries they use a comma instead of decimal points:

18,5909 -68,9919

This causes the app problems when trying to map the annotations onto the map because it doesn’t understand the US format (or vice versa).

My question is this: What would be the best way to check Region Format of the iPhone user. I would like to check which country the user is set to and then re-direct them to another xml file formatted for them. Can you possibly provide any insight to this?



30 Jul 2010, 09:12
Ryan (2 posts)

This is how I solved this problem, just checking the actual locale of the iPhone against an array and downloading the correct file based on comma or decimal based system. Something like this:

    NSString *locale = [[NSLocale currentLocale] localeIdentifier];
    NSLog(@"current locale: %@", locale);

    NSMutableArray *array = [[NSMutableArray alloc] initWithObjects: @"de_DE",@"de_AT", @"de_LU", @"fr_CH", @"fr_LU", @"fr_FR", @"fr_CA", @"fr_BE", @"fi_FI", @"el_CY", @"el_GR", @"hu_HU", @"is_IS", @"it_IT", @"lv_LV", @"lt_LT", @"mk_MK", @"no_NO", @"pl_PL", @"pt_BR", @"pt_PT", @"ro_RO", @"ru_RU", @"es_AR", @"es_BO", @"es_CL", @"es_CO", @"es_CR", @"es_EC", @"es_SV", @"es_GT", @"es_HN", @"es_NI", @"es_PA",@"es_PY", @"es_PE", @"es_ES", @"es_UY", @"es_VE", @"sv_SE", @"tr_TR", @"vi_VN", @"sq_AL", @"be_BY",@"bg_BG", @"ca_ES", @"hr_HR", @"cs_CZ", @"da_DK", @"nl_BE", @"nl_NL", @"en_ZA", @"el_GR", @"hu_HU",@"de_BE",@"af_ZA",@"af_NA",@"hy_AM",@"eu_ES",@"en_BE",@"et_EE",@"gl_ES",@"nb_NO",@"ro_MD",nil];

    if([array containsObject: locale])
        //This user has a region that uses commas to seperate GPS coordinates. Download comma based XML file. 
        //This user has a region that uses decimals to seperate GPS coordinates. Download decimal based XML file.
 [array release];
02 Aug 2010, 02:02
Bill Dudney (916 posts)

Hi Ryan,

Take a look at the ‘Internationalizing Data on Mac and iPhone’ talk from WWDC 2010, it has a ton of great advice on how to handle this kind of thing.

Good luck!

You must be logged in to comment