NSCompoundPredicate

While working on a side project for fun I had a need to query the Health app and retrieve workout samples from a given date range and of a given type.

The HealthKit APIs accept NSPredicate objects or you can use convenience functions that accept workout types or dates. To use both a date range and a workout type one should construct your own predicates and combine them with NSCompoundPredicate. This code gist (embedded below) shows a very simple use case for Swift 3.0.