Skip to content

Instantly share code, notes, and snippets.

Created Sep 17, 2014
What would you like to do?
Save Height to HealthKit
double height = _txtHeight.text.doubleValue;
HKUnit *inchUnit = [HKUnit inchUnit];
HKQuantity *heightQuantity = [HKQuantity quantityWithUnit:inchUnit doubleValue:height];
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
NSDate *now = [NSDate date];
HKQuantitySample *heightSample = [HKQuantitySample quantitySampleWithType:heightType quantity:heightQuantity startDate:now endDate:now];
[self.healthStore saveObject:heightSample withCompletion:^(BOOL success, NSError *error) {
[self retrieveHeight];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment