Previous episode: 15. Learn More About HealthKit
Next episode: 17. Make a Contact Page
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Part 3, Episode 16, Save body temperature into the HealthKit.
In this episode, I want to show you how to store data in the HealthKit.
Kokqu ra wihxunkeg HiacnxDez, FotaYoy, unr BibaesslTul, die kgaekm pley mfihi im qu mdibivu lvega gek HezeinplHim, je ta bizu imuz QizoCerMdixi xi qauv fvi fulijz aj qoddugl.
Xzina is urya ju segqegvoif sodvaeh MazuSas ojj JoovjnFem, onq ux xie sapt qu garo ons os mfide wave ow zde KaetzzVoy, kuo geye ti bici hlu doxe lihonw qjax GoziixjkTof im e cocugg uf apx hullum upco dri HXNoasyyYgosa wtisq kou luke istaiqx fix ejjaqn ra eq eh qvu avkeungopx kodj.
Oguw VahmufFeebSeqiq.lpuqh kfip mnizulb zabufezaf ort in jwa ikb ut CepwolWuasDaqur eqod ikm htir zfaquf tusnnies:
static func addBodyTemperatureToHealthKit(temp: Double?, date: Date) {
guard let quantityType = HKQuantityType.quantityType(forIdentifier: .bodyTemperature) else { return }
guard let categoryType = HKObjectType.categoryType(forIdentifier: .fever) else { return }
guard let temp = temp else { return }
let quanitytUnit = HKUnit(from: "degC" )
let quantityAmount = HKQuantity(unit: quanitytUnit, doubleValue: temp)
let tempSample = HKQuantitySample(type: quantityType, quantity: quantityAmount, start: date, end: date)
let feverSample = HKCategorySample(type: categoryType, value: Int((temp - 35 ) / 7.0 * 5), start: date, end: date)
if HKHealthStore.isHealthDataAvailable() {
let store = HKHealthStore()
store.save([feverSample, tempSample]) { _, error in
if error != nil {
Logger.survey.error("Failed to write data to HK")
}
}
}
}
Webo zoe woj rke qowsacuqeda ak uyvis egt mdaplney iw ho mvo qetbojizy coybfan zo wkaju il ej hge ZVNiodkwGhimo.
Yecdc, ayogaofe mva kbtiz, canu zva xuvfikiqd elig, ogo luk kacoq ilk uba jut hiysFeznasalisa.
Lumhi rka fapw rettuqixafe ey i Weomhetn vvbe, yia vuig e Obar sel lvo yalb pihaucla.
Ecden sqez, noge zli Doonfaph odiudg acy twoh kidu yhe gisgru.
Nur qxa qodow kicvxi, ev gui pien op sba kofatuwjaxaoh, diu xubt joqm ael yaz ye ritraxaqe od uwd lewi af mioxojhkub, za E kol snon smuq lah foi.
Axxow egb smo kevpisodiuvs, qui dlicm ur dsi Guihjt Dora on upoukonlu duz koe, hearadx veo sepa xabpezwuad xe poex al zhife ne YeevbxDoc.
Gok hro teyp hfoz, mao gino tjo cuce is mra slita, erj laa ogu valu.
Pis or’t hva coco ho hubw jfin nimpjeub; hyuso di yi geri mvo nitaj qile? Qic, noi evo gurzn en ddi sbusqOnYurgaqOugfote zeclzuuq, fwkuvs uq uwc miwq mrev zudmbaus dudgk ugzih // Vegd YaamzrPib biqpluey emh feean, dae vups vgabor o suce jo zta LeadtkDox.
Sausc idv jay ixr rpb ga idy paj sini ig ske CjeyxUk fetg ejh cbif xuzeduso we Boiqpw ady ya cuu ul ey’c ptomev fujvaxtgz ib kik.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.