kodeco.com Forums

Accessing Heart Rate Data for Your ResearchKit Study

In this tutorial, you'll learn how to easily access heart rate data from HealthKit and use it in a ResearchKit study.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1446-accessing-heart-rate-data-for-your-researchkit-study

Thank you Matt for this really helpful tutorial.

To use real data instead of mockdata, do I remove this line:
let heartRateQuantity = HKQuantity(unit: HKUnit(fromString: “count/min”),
doubleValue: Double(arc4random_uniform(80) + 100))
Or do I just remove ‘doubleValue: Double(arc4random_uniform(80) + 100))’
I’m having trouble understanding which part of the code is the mock rate and which part is real?

Also If I want to stop the measure on a ‘stop’ button tapped (eg ‘stopped walking’, like you had a button for started walking), instead of the set duration timer, how can I do that?

eg You noted that ORKActiveStep is the set duration lines “class MusicStep: ORKActiveStep {
var clip: MusicClip!
Do I remove that code as well as all of the code in ‘Music Step’? And then just as you have the UI Button for ‘walktapped’ which leads to HealthKitManager.startMockHeartData(), I can add another UI button for HealthKitManager.startMockHeartData()

Hi, I am also wondering how to use the real data, have you found a solution?

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]