I\'m currently using Healthkit in an app and have no problems getting info for most types, but am having trouble with the Heart Rate. Every time I try to read a sample, I get \
if you want to get averageQuantity ask for it in your HKStatisticsQuery options. otherwise it will always be nil (ie. not calculated): options parameter should be set to HKStatisticsOptionDiscreteAverage, NOT HKStatisticsOptionNone
From what I read and if I'm correct, you are trying to read the heart rate from the beginning of the day up till now.
Check your start date and end date by logging them out after using a date formatter. Could be possible that the start time and the end time are the same, that is why you get 0 as the result.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
NSString *dateString = [dateFormatter stringFromDate:beginOfDay];
NSLog(@"%@", dateString);
You should also set the hour minute and second to zero to ensure that you are getting a time of the start of the day.
NSDateComponents *components = [calendar components:NSCalendarUnitYear| NSCalendarUnitMonth | NSCalendarUnitDay
fromDate:now];
components.hour = 0;
components.minute = 0;
components.second = 0;
Hope this helps.