Contents

HKSampleQuery

A general query that returns a snapshot of all the matching samples currently saved in the HealthKit store.

Declaration

class HKSampleQuery

Mentioned in

Overview

You can use sample queries to search for any concrete subclasses of the HKSample class, including HKCategorySample, HKCorrelation, HKQuantitySample, and HKWorkout objects.

The sample query returns sample objects that match the provided type and predicate. You can provide a sort order for the returned samples, or limit the number of samples returned. Other query classes can be used to perform more specialized searches and calculations. For more information, see HKQuery.

Sample queries are immutable: The query’s properties are set when the query is first created, and they can’t change.

Topics

Creating Sample Queries

Getting Property Data

Setting Limits

See Also

Basic queries