HKSamplePredicate
A predicate for queries that return a collection of matching sample objects.
Declaration
struct HKSamplePredicate<Sample> where Sample : HKSampleOverview
The HKSamplePredicate structure bundles an HKSampleType and an optional NSPredicate. The structure is generic. You can create it for any HKSampleType subclass, and it automatically sets the Sample type to the matching HKSampleType subtype. As a result, any query that you build using this structure returns properly typed results.
To create an HKSamplePredicate instance, call one of its constructor methods.
let stepType = HKQuantityType(.stepCount)
let predicate = HKSamplePredicate.quantitySample(type: stepType)
let descriptor = HKSampleQueryDescriptor(
predicates:[predicate],
sortDescriptors: [],
limit: 10)
// The results are an array of HKQuantitySample objects.
let results = try await descriptor.result(for: store)Topics
Creating Sample Predicates
audiogram(_:)categorySample(type:predicate:)clinicalRecord(type:predicate:)correlation(type:predicate:)electrocardiogram(_:)heartbeatSeries(_:)quantitySample(type:predicate:)sample(type:predicate:)visionPrescription(_:)workout(_:)workoutRoute(_:)