<!--
{
  "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/HKCategorySample",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKCategorySample"
  },
  "title" : "HKCategorySample"
}
-->

# HKCategorySample

A sample with values from a short list of possible values.

```
class HKCategorySample
```

## Overview

You can use category samples to record data associated with a [`HKCategoryType`](/documentation/HealthKit/HKCategoryType). The value for the sample must come from the appropriate category value enumeration. Each category type uses its own enumeration. Individual samples represent a value and time period. Samples with different values may have overlapping time intervals.

The [`HKCategorySample`](/documentation/HealthKit/HKCategorySample) class is a concrete subclass of the [`HKSample`](/documentation/HealthKit/HKSample) class. Category samples are immutable: You set the sample’s properties when you create it, and they can’t change.

### Extend Category Samples

Like many HealthKit classes, don’t subclass the `HKCategorySample` class. You may extend the `HKCategorySample` class by adding metadata with custom keys as appropriate for your app.

For more information, see [`init(type:value:start:end:metadata:)`](/documentation/HealthKit/HKCategorySample/init(type:value:start:end:metadata:)).

## Topics

### Creating Category Samples

[`+  categorySampleWithType:value:startDate:endDate:`](/documentation/HealthKit/HKCategorySample/init(type:value:start:end:))

Creates a newly instantiated category sample.

[`+  categorySampleWithType:value:startDate:endDate:metadata:`](/documentation/HealthKit/HKCategorySample/init(type:value:start:end:metadata:))

Creates a newly instantiated category sample with the provided metadata.

[`+  categorySampleWithType:value:startDate:endDate:device:metadata:`](/documentation/HealthKit/HKCategorySample/init(type:value:start:end:device:metadata:))

Creates a newly instantiated category sample including the provided device and metadata.

### Getting Property Data

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

The category type for this sample.

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

The category value for this sample.

### Assigning Values

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

Categories that are undefined.

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

Categories that represent the user’s cervical mucus quality.

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

Categories that indicate the amount of menstrual flow for a given sample.

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

Categories that represent the result of an ovulation home test.

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

The type of contraceptive.

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

Categories that represent the result of a sleep analysis.

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

Categories that represent change in appetite.

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

Categories that indicate whether a symptom is present.

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

Categories that represent the severity of a symptom.

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

Exposure events for environmental audio.

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

Exposure events for headphone audio.

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

A value that indicates a low-level cardio fitness event.

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

A classification of a score based on the steadiness of the user’s gait.

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

The value of an event triggered by a reduced score for the steadiness of the user’s gait.

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

Category values that indicate the results of a home pregnancy test.

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

A category value that indicates the result from a home progesterone test.

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

Categories that indicate audio exposure events.

### Specifying Predicate Key Paths

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

The key path for accessing the category sample’s value.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)