Instance Method


Compares two values after converting them to the same units.


- (NSComparisonResult)compare:(HKQuantity *)quantity;



The quantity to compare. This method throws an exception if the quantities do not have compatible units (NSInvalidArgumentException).

Return Value

NSOrderedDescending if the parameter is less than the receiver. NSOrderedAscending if the parameter is greater than the receiver. NSOrderedSame if the quantities are equal.


Returns whether the quantity argument is less than, equal to, or greater than the current quantity. This method automatically converts the quantities into the same units before comparing the values. You just need to ensure that the quantities have compatible units.

In most cases, the compatible units are clear from context. To see the unit types associated with different quantity sample types, see the type identifiers in HealthKit Constants.

If you need to programmatically check whether a particular unit is compatible with a particular quantity, call the quantity’s isCompatibleWithUnit: method.

See Also