title: HealthKit query for swimming strokes / style per lap
body: <p>I managed to query for swimming strokes but it's just the cumulative sum.</p>
  <pre><code>private func querySwimStrokeCount(for sample: HKSample) {
      let strokeCount = HKSampleType.quantityType(forIdentifier: HKQuantityTypeIdentifier.swimmingStrokeCount)!
      let sampleDate = HKQuery.predicateForSamples(withStart: sample.startDate, end: sample.endDate, options: [])
      
      let query = HKStatisticsQuery(quantityType: strokeCount,
                                    quantitySamplePredicate: sampleDate,
                                    options: .cumulativeSum) { (query, statisticsOrNil, errorOrNil) in
          
          guard let statistics = statisticsOrNil else {
              return
          }
          
          let sum = statistics.sumQuantity()
          let strokeCount = sum?.doubleValue(for: HKUnit.count()) ?? 0
          
          DispatchQueue.main.async {
              self.strokeCount = Int(strokeCount)
          }
      }
      
      HKHealthStore().execute(query)
  }
  </code></pre>
  <p>Now I came to the question how do I get the stroke count per lap and the swimming style for that lap? The Apple Health App shows this data (see screenshots) but I have no clue how to query for them.</p>
  <p>Any help appreciated!</p>
  <p><a href="https://i.stack.imgur.com/LjuyD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LjuyD.png" alt="Health App Swimming Strokes per lap" /></a></p>
  <p><a href="https://i.stack.imgur.com/M3oiG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M3oiG.png" alt="Health App Swimming Style for strokes" /></a></p>