Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
iOS update the current weight of the user
// Some weight in gram
double weightInGram = 83400.f;
// Create an instance of HKQuantityType and
// HKQuantity to specify the data type and value
// you want to update
NSDate *now = [NSDate date];
HKQuantityType *hkQuantityType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
HKQuantity *hkQuantity = [HKQuantity quantityWithUnit:[HKUnit gramUnit] doubleValue:weightInGram];
// Create the concrete sample
HKQuantitySample *weightSample = [HKQuantitySample quantitySampleWithType:hkQuantityType
// Update the weight in the health store
[healthStore saveObject:weightSample withCompletion:^(BOOL success, NSError *error) {
// ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.