将锻炼保存到 iOS 健康存储时,没有任何 Apple Watch,应用程序应如何计算总能量消耗?
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) {
}];
谢谢
最佳答案
除非您有 Apple Watch,否则 Apple 不会为您提供开箱即用的方法。
Strava 和 Nike Run 等应用程序根据以下因素计算消耗的卡路里:
- 性别
- 体重
- 运行距离
- 运行时长
您可以在 Google 上查找公式,甚至可以在 Stack Exchange 网络上的其他地方查找公式:https://fitness.stackexchange.com/questions/15608/energy-expenditure-calories-burned-equation-for-running进而链接到网络上的优质资源
关于ios - 在 iOS 上,如果没有 Apple Watch,如何收集锻炼时消耗的总能量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58365702/