NSMeasurementFormatter is an Apple Foundation framework data formatter that provides localized representations of units and measurements. It is used to create localized representations of NSMeasurement objects. The formatter takes into account the specified locale, unitStyle, and unitOptions when producing string representations of units and measurements.
Questions tagged [nsmeasurementformatter]
9 questions
10
votes
2 answers
Choosing units with MeasurementFormatter
This is similar to a question I asked yesterday but the answer I got doesn't seem to work in this case.
I'm getting altitude values in meters from Core Location. I want to display these in a localized form. As an example, the altitude where I am…

Tom Harrington
- 69,312
- 10
- 146
- 170
3
votes
1 answer
NSMeasurementFormatter shows Imperial weights but not metric weights?
I have implemented an NSMeasurementFormatter and am having an odd issue. When the app is loaded as en_US, I get all my weights loaded into the text boxes as pounds, brilliant. However when I switch my app to en_GB and load the same data, i get…

jwarris91
- 902
- 9
- 24
2
votes
1 answer
Swift NSmeasurement UnitMass.stones
Playing around with swift measurements, I have come across a questionable value conversion. As illustrated below kg to lb is correct, but the same kilogram to stone conversion is not correct, unless I'm not understanding the conversion…
user1162328
2
votes
1 answer
Use MeasurementFormatter to display meters as feet
I'm having trouble getting the new MeasurementFormatter class to give me results in appropriate units. I have values in meters that I want to display in localized strings, either meters or feet depending on the user's locale.
I have this:
let meters…

Tom Harrington
- 69,312
- 10
- 146
- 170
1
vote
0 answers
MeasurementsFormatter - convert number to "X ft, Y in"
here's my case - I have a number, for example 5.9, and I want to produce a String like "5 ft, 11 in". Can this be accomplished using MeasurementsFormatter API?
I see in deprecated API's sources, LengthFormatter, that this was implemented:…

AndrzejZ
- 245
- 2
- 10
0
votes
1 answer
Force NSMeasurementFormatter to get value over 1 with NSMeasurementFormatterUnitOptionsNaturalScale optiion
If we put the value 100g into a NSUnit and use NSMeasurementFormatterUnitOptionsNaturalScale to get a translated String, the result is 3.52 oz for Imperial system.
The problem is with Metric, the result is 0,1 kg which is the good value but i need…

hbdev
- 52
- 6
0
votes
1 answer
How can I handle the MeasurementFormatter using the kilometersPerHour UnitType?
I need to display the integer from km/h values using the MeasurementFormatter on Objective-C.
Is there any sample available?
NSMeasurementFormatter *formatter = [[NSMeasurementFormatter alloc] init];
formatter.unitStyle =…

Nandhakumar
- 64
- 2
- 12
0
votes
1 answer
Best way to extend Measurement Unit with non existing type?
I'm making a health app, and thought it would be nice to create some custom HKUnit to represent some data by extending HKUnit, but HealthKit documentation says we shouldn't extend or subclass it, so I went to Measurements (Dimension) to try creating…

Einharch
- 69
- 1
- 4
0
votes
1 answer
How to convert 1000 lbs to 1 short ton with current locale in Swift iOS depending on locale?
How do I to convert 1000kg to 1 short ton with current locale in Swift iOS?
The input is in kg.
I want to output the string in either pounds or short tons depending on if it was over or below 1000 short tons.
However if the default locale was in…

user805981
- 9,979
- 8
- 44
- 64