<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKElectrocardiogramQueryDescriptor",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit34HKElectrocardiogramQueryDescriptorV"
  },
  "title" : "HKElectrocardiogramQueryDescriptor"
}
-->

# HKElectrocardiogramQueryDescriptor

A query interface that reads the underlying voltage measurements for an electrocardiogram sample using Swift concurrency.

```
struct HKElectrocardiogramQueryDescriptor
```

## Overview

Use [`HKElectrocardiogramQueryDescriptor`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor) to access the individual voltage measurements associated with an [`HKElectrocardiogram`](/documentation/HealthKit/HKElectrocardiogram) sample. To read the individual voltage measurements, create an electrocardiogram query descriptor using the desired sample, and then call the [`results(for:)`](/documentation/HealthKit/HKHeartbeatSeriesQueryDescriptor/results(for:)) method on the descriptor.

```swift
// Create the descriptor.
let ecgDescriptor = HKElectrocardiogramQueryDescriptor(myElectrocardiogram)

// Get the AsyncSequence that returns individual voltage measurements.
let voltages = ecgDescriptor.results(for: store)

// Access each voltage measurement.
for try await measurement in voltages {
    
    // Process the results here.
    print(measurement.quantity(for: .appleWatchSimilarToLeadI) ?? "No Measurement")
    print(measurement.timeSinceSampleStart)
}
```

While this method returns an <doc://com.apple.documentation/documentation/Swift/AsyncSequence>, unlike the long-running queries, this sequence has a finite size. Iterating over the sequence asynchronously returns voltage measurements, automatically terminating after you receive all the measurements.

## Topics

### Creating Electrocardiogram Query Descriptors

[`init(HKElectrocardiogram)`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor/init(_:))

Creates a query descriptor that reads voltage measurements from the provided electrocardiogram sample.

### Running Queries

[`func results(for: HKHealthStore) -> HKElectrocardiogramQueryDescriptor.Results`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor/results(for:))

Runs a one-shot query that returns an asynchronous sequence of data representing individual heartbeats.

[`struct Results`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor/Results)

An asynchronous sequence that emits data about individual voltage measurements from an electrocardiogram sample.

### Accessing Query Properties

[`var electrocardiogram: HKElectrocardiogram`](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor/electrocardiogram)

The sample that contains the voltage measurements.

### Default Implementations

[HKAsyncSequenceQuery Implementations](/documentation/HealthKit/HKElectrocardiogramQueryDescriptor/HKAsyncSequenceQuery-Implementations)

## Relationships

### Conforms To

[`HKAsyncSequenceQuery`](/documentation/HealthKit/HKAsyncSequenceQuery)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)