HKCategory class is a concrete subclass of the
HKSample class. This class describes samples whose values are selected from an enumeration of values.
- iOS 8.0+
- watchOS 2.0+
For example, you can use category samples to record sleep data using the
HKCategory enumeration. Individual samples represent time periods when the user is in bed or asleep. Samples with different values may have overlapping time intervals. For example, when the user is both in bed and asleep, you would create an in-bed sample and an asleep sample with overlapping times.
Category samples are immutable: The sample’s properties are set when the object is first created, and they cannot change.
Like many HealthKit classes, the
HKCategory class should not be subclassed.
You may extend the
HKCategory class by adding metadata with custom keys as appropriate for your app. For more information, see