---
title: "splitTotalEnergy(_:start:end:resultsHandler:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/splittotalenergy(_:start:end:resultshandler:)"
---

# splitTotalEnergy(_:start:end:resultsHandler:)

Calculates the active and resting energy burned based on the total energy burned over the given duration.

## Declaration

```swift
func splitTotalEnergy(_ totalEnergy: HKQuantity, start startDate: Date, end endDate: Date, resultsHandler: @escaping @Sendable (HKQuantity?, HKQuantity?, (any Error)?) -> Void)
```

## Parameters

- `totalEnergy`: A quantity object containing the total energy burned during the specified time period.
- `startDate`: A date object representing the activity’s start time.
- `endDate`: A date object representing the activity’s end time.
- `resultsHandler`: A block that is called as soon as the calculations are complete. This block is passed the following parameters:

## Discussion

Discussion This method operates asynchronously. As soon as the calculation is finished, it calls the completion block on a background queue. This method splits the total calories into the active and resting calories, based on the user’s estimated resting metabolic rate and the activity’s duration. Use the resulting values to create samples representing both the active and resting energy burned. Active energy samples contribute to Apple Watch’s activity monitoring.

## See Also

### Managing workouts

- [recoverActiveWorkoutSession(completion:)](healthkit/hkhealthstore/recoveractiveworkoutsession(completion:).md)
