似乎 HKStatisticsCollectionQuery 在 iOS 9.3 中速度非常慢。可能需要超过 40 秒的时间才能返回一年中的每小时活跃卡路里统计数据,而之前需要 1 或更少的时间。
let predicate = HKQuery.predicateForSamplesWithStartDate(anchorDate, endDate: endDate, options: [])
let query = HKStatisticsCollectionQuery(quantityType: quantityType,
quantitySamplePredicate: predicate,
options: statisticOptions,
anchorDate: anchorDate,
intervalComponents: interval)