nsmeasurement

NSMassFormatter can't convert grams to lbs (NSUnitMass) or display value

十年热恋 提交于 2019-12-04 07:09:41
问题 I am trying to modernize my API calls and want to utilize NSMassFormatter . The problem is simple. I can't get any output (aiming for imperial locale). NSMeasurement's description is correct. How to make NSMassFormatter to display "123 lbs" weight automatically if I provide grams? NSNumber *weightInGrams = @(62453.0); NSMassFormatter *weightFormatter = [NSMassFormatter new]; weightFormatter.forPersonMassUse = YES; weightFormatter.numberFormatter.locale = [NSLocale localeWithLocaleIdentifier:@

NSMassFormatter can't convert grams to lbs (NSUnitMass) or display value

浪子不回头ぞ 提交于 2019-12-02 12:07:25
I am trying to modernize my API calls and want to utilize NSMassFormatter . The problem is simple. I can't get any output (aiming for imperial locale). NSMeasurement's description is correct. How to make NSMassFormatter to display "123 lbs" weight automatically if I provide grams? NSNumber *weightInGrams = @(62453.0); NSMassFormatter *weightFormatter = [NSMassFormatter new]; weightFormatter.forPersonMassUse = YES; weightFormatter.numberFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_UK"]; NSMeasurement *weightMeasurement = [[NSMeasurement alloc] initWithDoubleValue:[weightInGrams