ios - 忽略来自 Apple Health 应用程序的手动条目作为数据源

标签 ios healthkit

您好,我正在编写一个从 Apples Health 应用程序获取数据的健身应用程序。

到目前为止一切顺利。

问题:在 Health 应用程序中,可以手动输入数据,这使得作弊成为可能。

问题:如何排除或忽略这个特定的数据条目。

Just the Data with "Source: Health" so i've still the possibility to read data from a random Fitness tracker.

最佳答案

HealthKit 中由用户手动输入的示例将具有 HKMetadataKeyWasUserEntered 元数据键的 YES 值。要创建仅匹配用户输入的样本的谓词,您可以使用以下方法:

[NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];

请注意,这必须表述为 value != YES,因为键的值可以是 YES、NO 或 nil,nil 表示 NO。

关于ios - 忽略来自 Apple Health 应用程序的手动条目作为数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31184628/

相关文章:

ios - View 之间的索引值传递

ios - XCTAssertThrows 在断点处停止

ios - '传递给不带参数的调用的参数'实例化 HKWorkoutRouteQuery

ios - HealthKit 请求授权(toShare :, 读取,完成 : ) : is there are way to know whether it was promped at least once?

swift - 如何使用不是主线程的线程来等待类静态 Bool 变量为真?

iphone - 在 UIScrollView 中禁用垂直滚动

ios - 如何使用没有下划线的 NSMutableAttributedString 添加链接?

iOS Healthkit 阅读锻炼

swift - 如何在 Xcode/Swift com.apple.developer.healthkit.background-delivery 中添加此权利?

objective-c - ASIHTTPRequest 和 NSURLRequest 不同的结果