<!--
{
  "availability" : [
    "iOS: 11.0.0 - 18.0.0",
    "iPadOS: 11.0.0 - 18.0.0",
    "macCatalyst: 13.0.0 - 18.0.0",
    "macOS: 13.0.0 - 15.0.0",
    "visionOS: 1.0.0 - 2.0.0",
    "watchOS: 4.0.0 - 11.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuery/predicateForWorkouts(with:totalFlightsClimbed:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForWorkoutsWithOperatorType:totalFlightsClimbed:"
  },
  "title" : "predicateForWorkouts(with:totalFlightsClimbed:)"
}
-->

# predicateForWorkouts(with:totalFlightsClimbed:)

Returns a predicate that matches workout samples based on the number of flights climbed.

```
class func predicateForWorkouts(with operatorType: NSComparisonPredicate.Operator, totalFlightsClimbed: HKQuantity) -> NSPredicate
```

## Parameters

`operatorType`

The operator to use when comparing the sample to the target number of flights climbed.

`totalFlightsClimbed`

A quantity representing the target number of flights climbed.

## Return Value

A predicate that matches workouts based on the number of flights climbed.

## Discussion

This convenience method creates a predicate that compares the total flights climbed during a workout with a target number of flights climbed. The following sample uses the convenience method and a predicate format string to create equivalent predicates.

```swift
let flightsClimbed = HKQuantity(unit: HKUnit.count(), doubleValue: 10.0)
let tenFlightsClimbed = HKQuery.predicateForWorkouts(with: .greaterThanOrEqualTo, totalFlightsClimbed: flightsClimbed)

// Creating a predicate using a predicate format string.
let explicitTenFlightsClimbed = NSPredicate(format: "%K >= %@",
                                            HKPredicateKeyPathWorkoutTotalFlightsClimbed,
                                            flightsClimbed)
```

## See Also

[`let HKPredicateKeyPathWorkoutTotalFlightsClimbed: String`](/documentation/HealthKit/HKPredicateKeyPathWorkoutTotalFlightsClimbed)

The key path for accessing the total number of flights of stairs climbed during the workout.



---

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)