ios - How do I construct a HealthKit HKUnit for mmol/L (millimoles per liter) for Blood Glucose values? -
blood glucose values added in health in ios 8.2: https://support.apple.com/en-us/ht203113
how construct healthkit hkunit mmol/l (millimoles per liter) blood glucose values?
the following both throw exceptions: terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'unable parse factorization string...
hkunit *mmolperl = [hkunit unitfromstring:@"mmol<molar mass>/l"]; hkunit *mmolperl = [hkunit unitfromstring:@"mmol/l"];
can confirm examples provided don't work (every permutation), alternative mg/dl
unit does.
to sum up, both proposed approaches work, similar (with approach proposed @cbartel constant rounded, not other) results regarding structure of resulting hkunit:
printing description of mmolperl->_baseunits->_factors: nsmaptable { [6] mmol<180.15588> -> 1 [7] l -> -1 }
i'd use shorter form using provided constant:
hkunit *mmolperl = [hkunit unitfromstring:[nsstring stringwithformat:@"mmol<%f>/l",hkunitmolarmassbloodglucose]];
Comments
Post a Comment