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はい。 'てみましょうhealthKitTypesToWrite =セット(配列リテラル:HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.activeEnergyBurned)〕HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.bodyMass)〕HKObjectType.quantityType(forIdentifier:HKQuantityTypeIdentifier.stepCount)!)' –