Skip to content

Instantly share code, notes, and snippets.

@max6363
Created May 8, 2018 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max6363/580e82e1b6e80355b4120dc5ab7aa041 to your computer and use it in GitHub Desktop.
Save max6363/580e82e1b6e80355b4120dc5ab7aa041 to your computer and use it in GitHub Desktop.
/**
On Write Steps Action
*/
- (IBAction)onWriteStepsAction:(id)sender {
// Steps
NSInteger steps = 100;
// Get date
NSDate *now = [NSDate date];
// Get startdate (before 60 seconds from now)
NSDate *startDate = [now dateByAddingTimeInterval:-60];
// Set end date
NSDate *endDate = now;
// Write steps with startdate, enddate
[[HealthKitManager sharedInstance] writeSteps:steps
startDate:startDate
endDate:endDate withFinishBlock:^(NSError *error) {
// result block
if (error) {
// handle error
NSLog(@"error : %@",error);
} else {
// success writing steps
}
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment