[问题] 取得Health app中每一笔心率资料

楼主: pseudocode   2015-05-18 16:39:14
最近在survey Healthkit的应用
目前试着想要透过自己开发的app
将心率写入Health app中以及将Health app所有的心率读回自己的app
写入的话是可以以每一笔为单位分别写入,
但我想要将Health app里每一笔心率的资料读回自己开发的app好像却不行
在HKStatistics中看到似乎只能得到最大、最小及平均值
不知是否有办法取得每一笔的资料
http://i.imgur.com/N2IvgFm.png
谢谢
解决了 谢谢大大提示
HKQuantityType *heartRateType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeartRate];
NSSortDescriptor *timeSortDescriptor= [[NSSortDescriptor alloc] initWithKey: HKSampleSortIdentifierEndDate ascending: YES];
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType: heartRateType predicate: nil limit: HKObjectQueryNoLimit sortDescriptors: @[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
for (HKQuantitySample *quantitySample in results) {
HKQuantity *quantity = quantitySample.quantity;
NSLog(@"%f", [quantity doubleValueForUnit:[HKUnit unitFromString: @"count/min"]]);
}
}];
[self.healthStore executeQuery:query];
作者: fishead1116 (DD鱼)   2015-05-18 17:12:00
HKSampleQuery

Links booklink

Contact Us: admin [ a t ] ucptt.com