Skip to content

Instantly share code, notes, and snippets.

@jault3
Created October 23, 2014 05:34
Show Gist options
  • Save jault3/ec82d70e932210c19b31 to your computer and use it in GitHub Desktop.
Save jault3/ec82d70e932210c19b31 to your computer and use it in GitHub Desktop.
QueryRecentLogs.m
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:[HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning]
predicate:[HKSampleQuery predicateForObjectsWithNoCorrelation]
limit:20
sortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:HKSampleSortIdentifierEndDate ascending:NO]]
resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
_runLogs = [NSMutableArray arrayWithArray:results];
[_tblRunLog reloadData];
});
}];
// don't forget to run the query after you create it!
[_healthStore executeQuery:query];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment