如何从健康应用程序的HKSample中获取严重性值



我想显示Health应用程序中的头痛数据。从HeatStore我得到了一系列[HKSamles]。如何获取HKCategoryValueSeverity?

从每个样本中,我可以获得startDate、endDate等

sampleType为HKCategoryTypeIdentifierHeadache。目前,我使用HKSample的debugDescription的第一个字符作为HKCategoryValueSeverity.rawValue 的数字

我有一个HealthKit HKSample的debugDescription。因此,在以下描述中,严重性rawValue为4->严重

4 1F6AED01-EB6A-4ADE-94C0-64F3F8B018BB " HKCategoryTypeIdentifierHeadache" (1), "iPhone13,3" (14.4) (2021-03-13 22:18:57 +0100 - 2021-03-13 22:28:57 +0100)

您获得的查询样本的类型为HKCategorySample,它具有一个属性值。参见

https://developer.apple.com/documentation/healthkit/hkcategorysample?language=objc

对于头痛,与其他症状类型一样,value是HKCategoryValueSeverity 类型的枚举

https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierheadache?language=objchttps://developer.apple.com/documentation/healthkit/hkcategoryvalueseverity?language=objc

您可以将值与可能的枚举列表进行比较以获得严重性。

最新更新