ios - 如何从健康应用程序的 HKSample 中获取严重性值
问题描述
我想显示来自 Health 应用程序的头痛数据。从 HealtStore 我得到一组 [HKSamles]。如何获得 HKCategoryValueSeverity?
从每个样本中,我可以获得 startDate、endDate 等。
sampleType 是 HKCategoryTypeIdentifierHeadache。目前我使用 HKSample 的 debugDescription 的第一个字符作为 HKCategoryValueSeverity.rawValue 的数字
我有一个 HealthKit HKSample 的 debugDescription。所以在下面的描述中,严重性 rawValue 是 4 -> .severe
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=objc https://developer.apple.com/documentation/healthkit/hkcategoryvalueseverity?language=objc
您可以将值与可能的枚举列表进行比较以获取严重性。
推荐阅读
- python - 什么添加到 python-behave 创建日志文件?
- javascript - v-for 的 VueJS forceUpdate 不起作用
- apache-spark-sql - 如何在 Spark SQL 中获取月份的第一个日期?
- java - 我们如何在 Android 应用程序中创建 Kafka 生产者?
- c# - Dotnet Core Windows 服务中的多个托管服务
- r - R中所有列的相同循环以创建新数据框
- python - 需要在网页中集成 Python 解释器,该网页将代码发布到执行它的服务器
- postgresql - 如何根据其他参数仅在某些记录上过滤表?
- rust - 为什么修改可变借用变量并保持其未使用不会引发错误
- apache-spark - apache spark phoenix 连接器不支持流式读取