swift - How would I display HealthKit Data in my iOS app? -


i messing around healthkit , want make simple app read number of activecaloriesburned healthkit , print onto viewcontroller. unsure if accessing data in healthmanager class, , unsure how call healthkit data print in viewcontroller.

i know have create class verify user allows app access healthkit data. first created class called healthmanager tackle first problem of verification, sure works properly:

class healthmanager {      let storage = hkhealthstore()      init()     {         checkauthorization()     }      func checkauthorization() -> bool {         var isenabled = true          if hkhealthstore.ishealthdataavailable() {              // explicitly requests calorie data             let calories = nsset(object: hkquantitytype.quantitytypeforidentifier(hkquantitytypeidentifieractiveenergyburned)!)              // requests authorization calorie data             storage.requestauthorizationtosharetypes(nil, readtypes: calories as? set<hkobjecttype>) { (success, error) -> void in                 isenabled = success             }         }          else {             isenabled = false         }          return isenabled      }  } 

but don't know next. , how read activecaloriesburned inside current class? , go returning value string , how pass information viewcontroller?

any appreciated!

you can access following information using health kit. - dateofbirth - bloodtype - biologicalsex - bodymass - height - workouttype

i think best create new independent "helathkithelper" singleton class , write logic in class.

through can call same code using different-2 controller classes.

some tutorial link http://natashatherobot.com/healthkit-getting-fitness-data/

http://www.raywenderlich.com/86336/ios-8-healthkit-swift-getting-started

hope you!


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -