Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a built in mechanism for Miles/KM interchangeability for iPhone?

I am currently working on a map-based iPhone application and wish to display some information to the user. For my application, it makes sense to have a setting of some sort where the user can choose Miles or Kilometers. Is there a built in mechanism (maybe similar to string localization) for doing this kind of value switching so that I can avoid an if-block around each time I want to display something to the user?

like image 929
TahoeWolverine Avatar asked Feb 22 '10 15:02

TahoeWolverine


People also ask

Can you change fitness app to miles?

Tap on Activity. Scroll down to Walking + Running Distance and tap. Scroll down to Unit and tap. Choose between km and mi for kilometers and miles.

How do I change Google Maps from km to miles on my iPhone?

The latest version of Google Maps for iOS added a small feature that's really useful: manually changing distance units. Just tap the "people" icon next to the search box, tap the "wheel" icon, go to the "distance units" section and select "miles" or "kilometres".


1 Answers

Take a look at NSLocale. You should be able to get the current locale using [NSLocale currentLocale]. Then call [theLocale objectForKey: NSLocaleMeasurementSystem] and look at the results which should tell you if the users locale uses the metric system. The docs for NSLocale have a constants section which list all of the values that can be passed to the locale.

Using this you would make your own function that could be used in your program to return your distance in a locale specific way.

like image 85
Jon Steinmetz Avatar answered Sep 18 '22 09:09

Jon Steinmetz