---
title: HKDiscreteQuantitySample
framework: healthkit
role: symbol
role_heading: Class
path: healthkit/hkdiscretequantitysample
---

# HKDiscreteQuantitySample

A sample that represents a discrete quantity.

## Declaration

```swift
class HKDiscreteQuantitySample
```

## Mentioned in

Accessing condensed workout samples

## Overview

Overview A quantity sample contains one or more HKQuantity objects. Each quantity represents a single piece of data with a single numeric value and the value’s associated units. Use these samples to store data representing independent measurements, such as height, heart rate, or temperature. The HKDiscreteQuantitySample class is a concrete subclass of the HKQuantitySample class. Discrete quantity samples are immutable; you set the sample’s properties when you create it, and they cannot change. Extend Discrete Quantity Samples Like many HealthKit classes, you should not subclass the HKDiscreteQuantitySample class. You may extend this class by adding metadata with custom keys to save related data used by your app. For more information, see init(type:quantity:start:end:metadata:).

## Topics

### Accessing Calculated Values

- [averageQuantity](healthkit/hkdiscretequantitysample/averagequantity.md)
- [maximumQuantity](healthkit/hkdiscretequantitysample/maximumquantity.md)
- [minimumQuantity](healthkit/hkdiscretequantitysample/minimumquantity.md)
- [mostRecentQuantity](healthkit/hkdiscretequantitysample/mostrecentquantity.md)
- [mostRecentQuantityDateInterval](healthkit/hkdiscretequantitysample/mostrecentquantitydateinterval.md)

### Specifying Predicate Key Paths

- [HKPredicateKeyPathMin](healthkit/hkpredicatekeypathmin.md)
- [HKPredicateKeyPathAverage](healthkit/hkpredicatekeypathaverage.md)
- [HKPredicateKeyPathMax](healthkit/hkpredicatekeypathmax.md)
- [HKPredicateKeyPathMostRecent](healthkit/hkpredicatekeypathmostrecent.md)
- [HKPredicateKeyPathMostRecentStartDate](healthkit/hkpredicatekeypathmostrecentstartdate.md)
- [HKPredicateKeyPathMostRecentEndDate](healthkit/hkpredicatekeypathmostrecentenddate.md)
- [HKPredicateKeyPathMostRecentDuration](healthkit/hkpredicatekeypathmostrecentduration.md)

## Relationships

### Inherits From

- [HKQuantitySample](healthkit/hkquantitysample.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Basic samples

- [HKCumulativeQuantitySample](healthkit/hkcumulativequantitysample.md)
- [HKQuantitySample](healthkit/hkquantitysample.md)
- [HKCategorySample](healthkit/hkcategorysample.md)
- [HKCorrelation](healthkit/hkcorrelation.md)
- [Units and quantities](healthkit/units-and-quantities.md)
- [Metadata Keys](healthkit/metadata-keys.md)
