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

# HKSample

A HealthKit sample represents a piece of data associated with a start and end time.

```
class HKSample
```

## Overview

The `HKSample` class is an abstract class. You should never instantiate a `HKSample` object directly. Instead, you always work with one of its concrete subclasses: [`HKCategorySample`](/documentation/HealthKit/HKCategorySample), [`HKQuantitySample`](/documentation/HealthKit/HKQuantitySample), [`HKCorrelation`](/documentation/HealthKit/HKCorrelation), or [`HKWorkout`](/documentation/HealthKit/HKWorkout) classes.

HealthKit samples are all immutable: You set the sample’s properties when you create it, and they cannot change.

If the sample represents data over a duration, the start time must be earlier than the end time. If the sample represents data at a particular instant, the start and end times can be the same.

## Topics

### Accessing the Sample’s Data

[`startDate`](/documentation/HealthKit/HKSample/startDate)

The sample’s start date.

[`endDate`](/documentation/HealthKit/HKSample/endDate)

The sample’s end date.

[`hasUndeterminedDuration`](/documentation/HealthKit/HKSample/hasUndeterminedDuration)

Indicates whether the sample has an unknown duration.

[`sampleType`](/documentation/HealthKit/HKSample/sampleType)

The sample type.

### Specifying Sort Identifiers

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

A constant for sorting samples based on their start date.

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

A constant for sorting samples based on their end date.

### Specifying Predicate Key Paths

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

The key path for accessing the sample’s start date.

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

The key path for accessing the sample’s end date.

## Relationships

### Conforms To

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

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

[`NSCoding`](/documentation/Foundation/NSCoding)

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

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

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

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

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

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

### Inherited By

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)