A HealthKit sample represents a piece of data associated with a start and end time.
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
HKSample class is an abstract class. You should never instantiate a
HKSample object directly. Instead, you always work with one of its concrete subclasses:
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.