Returns a predicate that matches the objects with the specified universally unique identifiers (UUIDs).
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
Framework
- Health
Kit
Declaration
class func predicateForObjects(with UUIDs: Set<UUID>) -> NSPredicate
Parameters
UUIDs
The set of UUIDs to be matched.
Return Value
A predicate that matches the specified objects based on their UUIDs.
Discussion
HealthKit assigns a UUID to each object when it is saved to the HealthKit store. HealthKit uses these IDs to uniquely identify objects from the store. Use this convenience method to create a predicate that checks an object’s UUID against the provided set of UUIDs. The following sample uses both the convenience method and a predicate format string to create equivalent predicates.
let uuids = HKQuery.predicateForObjectsWithUUIDs(myUUIDs)
let explicitUUIDs =
NSPredicate(format: "%K IN %@", HKPredicateKeyPathUUID, myUUIDs)