本文介绍了忽略Apple Health应用程序中的手动条目作为数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

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

Hi I'm writing a Fitness App which gets its Data from Apples Health app.

到目前为止一切顺利。

问题:在Health应用程序中,可以手动创建可以作弊的数据条目。

Problem: in Health app it is possible to make manually data entries which makes it possible to cheat.

问题:如何排除或忽略此特定内容数据条目。

Question: how can i exclude or ignore this specific Data Entries.



推荐答案

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

Samples in HealthKit that were manually entered by the user will have have a YES value for the HKMetadataKeyWasUserEntered metadata key. To create a predicate that matches only samples that were not user-entered, you could do use the following:

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

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

Note that this must be formulated as value != YES because the value for the key could be YES, NO, or nil and nil implies NO.

这篇关于忽略Apple Health应用程序中的手动条目作为数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:46