【问题标题】:On iOS, without an Apple Watch, how to collect totalEnergyBurned for a workout?在 iOS 上,没有 Apple Watch,如何收集 totalEnergyBurned 进行锻炼?
【发布时间】:2019-10-13 16:46:38
【问题描述】:

在没有任何 Apple Watch 的情况下将锻炼保存到 iOS 健康商店时,应用应如何计算 totalEnergyBurned?

Apple 的示例应用对 totalEnergyBurned 使用硬编码值,但表示实际应用会根据传感器数据计算此值。

HKQuantity *energyBurned = [HKQuantity quantityWithUnit:[HKUnit kilocalorieUnit] doubleValue:425.0];

HKQuantity *distance = [HKQuantity quantityWithUnit:[HKUnit mileUnit] doubleValue:3.2];

HKWorkout *run = [HKWorkout workoutWithActivityType:HKWorkoutActivityTypeRunning
                                          startDate:start
                                            endDate:end
                                           duration:0
                                  totalEnergyBurned:energyBurned
                                      totalDistance:distance
                                           metadata:nil];

[self.healthStore saveObject:run withCompletion:^(BOOL success, NSError *error) {
}];

谢谢

【问题讨论】:

标签: ios objective-c healthkit


【解决方案1】:

除非您有 Apple Watch,否则 Apple 不会为您提供开箱即用的方法。

Strava 和 Nike Run 等应用根据以下因素计算消耗的卡路里:

  • 性别
  • 体重
  • 跑步距离
  • 运行持续时间

您可以在 google 上查找公式,甚至可以在 Stack Exchange 网络上的其他地方查找公式:https://fitness.stackexchange.com/questions/15608/energy-expenditure-calories-burned-equation-for-running 进而链接到网络上的优质资源

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 2015-11-14
    • 1970-01-01
    相关资源
    最近更新 更多