Evaluate, Convert and Format Units of Measure
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
UnitsKit Example.xcodeproj
UnitsKit Example
UnitsKit ExampleTests



Note: UnitsKit is not under active development.

Evaluates and Formats Units of Measurement

UnitsKit is a based around the SMQuantity subclass which contains a value and a unit. A quantity can be constructed using a value wrapped in a NSNumber and a NSString the represents the name or symbol of a unit. Quantities can be combined by using an operator such as add,subtract,multiply, or divide. Quantities can also be converted to other units. Finally Quantities can be formatted as an NSString by specifying how it should be displayed with options like names or symbols.


Build and run the UnitsKit Example project in Xcode to see an example of evaluating and formatting quantities.

Example Usage

SMQuantity *oneMeter = [[SMQuantity alloc] init];
[oneMeter setValue:@1];
[oneMeter setUnit:[quantityEvaluator derivedUnitFromString:@"meter"]];

// Display in either symbols or names
[quantityFormatter stringFromQuantity:oneMeter] // 1 m
[quantityFormatter setDisplaysInTermsOfSymbols:NO];
[quantityFormatter stringFromQuantity:oneMeter]; //1 meter

// Add or multiply
[quantityEvaluator evaluateQuantity:oneMeter withQuantity: oneMeter usingOperator:@"add"]; // 2 m
[quantityEvaluator evaluateQuantity:oneMeter withQuantity: oneMeter usingOperator:@"multiply"]; // 1 m^2


Steve Moser


UnitsKit is available under the MIT license. See the LICENSE file for more info.