<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKDiscreteQuantitySample",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKDiscreteQuantitySample"
  },
  "title" : "HKDiscreteQuantitySample"
}
-->

# HKDiscreteQuantitySample

A sample that represents a discrete quantity.

```
class HKDiscreteQuantitySample
```

## Overview

A quantity sample contains one or more [`HKQuantity`](/documentation/HealthKit/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`](/documentation/HealthKit/HKDiscreteQuantitySample) class is a concrete subclass of the [`HKQuantitySample`](/documentation/HealthKit/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`](/documentation/HealthKit/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:)`](/documentation/HealthKit/HKQuantitySample/init(type:quantity:start:end:metadata:)).

## Topics

### Accessing Calculated Values

[`averageQuantity`](/documentation/HealthKit/HKDiscreteQuantitySample/averageQuantity)

The average of all quantities contained by the sample.

[`maximumQuantity`](/documentation/HealthKit/HKDiscreteQuantitySample/maximumQuantity)

The maximum quantity contained by the sample.

[`minimumQuantity`](/documentation/HealthKit/HKDiscreteQuantitySample/minimumQuantity)

The minimum value contained by the sample.

[`mostRecentQuantity`](/documentation/HealthKit/HKDiscreteQuantitySample/mostRecentQuantity)

The most recent quantity contained by the sample.

[`mostRecentQuantityDateInterval`](/documentation/HealthKit/HKDiscreteQuantitySample/mostRecentQuantityDateInterval)

The date interval for the most recent quantity contained by the sample.

### Specifying Predicate Key Paths

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

The key path for the sample’s minimum quantity.

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

The key path for the sample’s average quantity.

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

The key path for the sample’s maximum quantity.

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

The key path for the sample’s most recent quantity.

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

The key path for the start date of the sample’s most recent quantity.

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

The key path for the end date of the sample’s most recent quantity.

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

A key path for the duration of the sample’s most recent quantity.



---

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)