Created
September 17, 2014 21:34
-
-
Save jault3/6051dcb3107cfeae9c22 to your computer and use it in GitHub Desktop.
Save Height to HealthKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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