---
title: "enableCollection(for:predicate:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkliveworkoutdatasource/enablecollection(for:predicate:)"
---

# enableCollection(for:predicate:)

Begins automatically calculating statistics for samples that match the quantity type and predicate.

## Declaration

```swift
func enableCollection(for quantityType: HKQuantityType, predicate: NSPredicate?)
```

## Mentioned in

Dividing a HealthKit workout into activities

## See Also

### Calculating statistics

- [disableCollection(for:)](healthkit/hkliveworkoutdatasource/disablecollection(for:).md)
