I have a distance as a float and I\'m looking for a way to format it nicely for human readers. Ideally, I\'d like it to change from m to km as it gets bigger, and to round the n
NSLengthFormatter which was introduced with iOS 8 and OS X 10.10 is an option people should be aware of.
NSLengthFormatter *lengthFormatter = [[NSLengthFormatter alloc] init];
lengthFormatter.unitStyle = NSFormattingUnitStyleShort;
NSLog(@"distance = %@", [lengthFormatter stringFromMeters:meters]);
However, NSLengthFormatter
has doesn't use Imperial units in those locales where they use metric except for distances.