代码之家  ›  专栏  ›  技术社区  ›  helloB

HealthKit:为特定来源和日期范围创建谓词

  •  0
  • helloB  · 技术社区  · 10 年前

    我需要在HealthKit中搜索特定给定数据源的数据。然而,当用户长时间没有登录时,我不需要太多数据,所以我只想返回一段特定的时间。如何为 HKQuery 两者都指定源(使用 HKQuery predicateForObjectsFromSources )并指定日期范围(使用 HKQuery predictForSamplesWithStartDate... )?

    1 回复  |  直到 10 年前
        1
  •  3
  •   Allan    10 年前

    您可以将多个 NSPredicate 实例使用 andPredicateWithSubpredicates: orPredicateWithSubpredicates: 上的类方法 NSCombinedPredicate 。请参见 class reference 了解更多详细信息。