[問題] 取得Health app中每一筆心率資料

看板MacDev作者時間9年前 (2015/05/18 16:39), 9年前編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
最近在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]; -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 210.61.97.145 ※ 文章網址: https://www.ptt.cc/bbs/MacDev/M.1431938357.A.3DE.html ※ 編輯: pseudocode (210.61.97.145), 05/18/2015 16:40:54

05/18 17:12, , 1F
HKSampleQuery
05/18 17:12, 1F
※ 編輯: pseudocode (210.61.97.145), 05/18/2015 17:44:32 ※ 編輯: pseudocode (210.61.97.145), 05/18/2015 17:46:02
文章代碼(AID): #1LMQKrFU (MacDev)