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

dgdosen

macrumors 68030
Original poster
Dec 13, 2003
2,817
1,463
Seattle
I'm trying to extract the measurement system from the locale on the iPhone with kCFLocaleMeasurementSystem or kCFLocaleUsesMetricSystem. They keep coming back to me as non-metric, even though I've rebooted the phone into UK/English.

Does anyone know if these constants are working? Or maybe how to use them :rolleyes:
 

dgdosen

macrumors 68030
Original poster
Dec 13, 2003
2,817
1,463
Seattle
Nevermind...

RTFM! I didn't see you needed to use CFLocaleGetValue to get at those constants. Very cool... You can even play with it in the simulator.

Code:
	CFLocaleRef currentLocale;
	CFBooleanRef usesMetric;
	NSString *measurement = [[NSString alloc] init];
	currentLocale = CFLocaleCopyCurrent();
	usesMetric = CFLocaleGetValue(currentLocale, kCFLocaleUsesMetricSystem);

	if (usesMetric == kCFBooleanFalse)
	{
		measurement = @"Miles";
	}
	else
	{	
		measurement = @"Kilimoters";
		
	}
 

grimjim

macrumors member
May 24, 2003
75
0
I didn't know you could do that.

But I should point out that here in the UK, although we use the metric system for pretty much everything else, we still use miles, so it might be better to allow the user to set the units using a preference option.

Just a thought....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.