<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 8.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKSampleQueryDescriptor/init(predicates:sortDescriptors:limit:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "s:9HealthKit23HKSampleQueryDescriptorV10predicates15sortDescriptors5limitACyxGSayAA0C9PredicateVyxGG_Say10Foundation04SortE0VyxGGSiSgtcfc"
  },
  "title" : "init(predicates:sortDescriptors:limit:)"
}
-->

# init(predicates:sortDescriptors:limit:)

Creates a sample query descriptor.

```
init(predicates: [HKSamplePredicate<Sample>], sortDescriptors: [SortDescriptor<Sample>], limit: Int? = nil)
```

## Parameters

`predicates`

An array of sample predicates that define the type of data that the query returns. To query for multiple types of data, provide a sample predicate for each type.

`sortDescriptors`

An array of sort descriptors that specify the order of the results that the query returns. If you don’t need the results in a specific order, pass an empty array.

`limit`

An optional value that specifies the maximum number of samples that the query returns. If you don’t specify the limit, the system returns all matching samples in the HealthKit store.

## Discussion

The system sets the descriptor’s `Output` type based on the `predicates` parameter.

---

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)