0
我有节奏,时间,英里,体重。我怎样才能获得卡路里? 这是一段代码。我如何获得卡路里?
seconds += 1
let (h,m,s) = secondsToHoursMinutesSeconds(seconds: Int(seconds))
let secondsQuantity = HKQuantity(unit: HKUnit.second(), doubleValue: Double(s))
let minutesQuantity = HKQuantity(unit: HKUnit.minute(), doubleValue: Double(m))
let hoursQuantity = HKQuantity(unit: HKUnit.hour(), doubleValue: Double(h))
displayTimeLabel.text = ""+hoursQuantity.description+" "+minutesQuantity.description+" "+secondsQuantity.description
let distanceQuantity = HKQuantity(unit: HKUnit.meter(), doubleValue: distance)
milesLbl.text = "" + distanceQuantity.description
paceLbl.text = ""+String((instantPace*3.6*10).rounded()/10)+" km/h"//"Pace: "+String((distance/seconds*3.6*10).rounded()/10)+" km/h"
let kg = 75
caloriesLbl.text = ???
你看过'HKQuantityTypeIdentifierActiveEnergyBurned'吗? –
@Olia_Pavliuk是的。 'let healthKitTypesToWrite = Set(arrayLiteral:HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.activeEnergyBurned)!,HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.bodyMass)!, HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.stepCount)!,''' –