---
title: "predicateForElectrocardiograms(classification:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkquery/predicateforelectrocardiograms(classification:)"
---

# predicateForElectrocardiograms(classification:)

Returns a predicate that matches electrocardiogram samples with the specified classification.

## Declaration

```swift
class func predicateForElectrocardiograms(classification: HKElectrocardiogram.Classification) -> NSPredicate
```

## Parameters

- `classification`: The target classification.

## Return Value

Return Value A predicate that matches electrocardiogram samples with the specified classification.

## Discussion

Discussion Use this convenience method to create a predicate that matches electrocardiogram samples with the specified classification. The following sample uses both the convenience method and a predicate format string to create equivalent predicates. let forClassification = HKQuery.predicateForElectrocardiograms(classification: .atrialFibrillation)

let classification = HKElectrocardiogram.Classification.atrialFibrillation.rawValue

let explicitForClassification = NSPredicate(format: "%K == %d", HKPredicateKeyPathECGClassification, classification)

## See Also

### Related Documentation

- [HKPredicateKeyPathECGClassification](healthkit/hkpredicatekeypathecgclassification.md)

### Creating electrocardiogram predicates

- [predicateForElectrocardiograms(symptomsStatus:)](healthkit/hkquery/predicateforelectrocardiograms(symptomsstatus:).md)
- [predicateForObjectsAssociated(electrocardiogram:)](healthkit/hkquery/predicateforobjectsassociated(electrocardiogram:).md)
