---
title: "init(type:start:end:objects:)"
framework: healthkit
role: symbol
role_heading: Initializer
path: "healthkit/hkcorrelation/init(type:start:end:objects:)"
---

# init(type:start:end:objects:)

Instantiates and returns a new correlation instance.

## Declaration

```swift
convenience init(type correlationType: HKCorrelationType, start startDate: Date, end endDate: Date, objects: Set<HKSample>)
```

## Parameters

- `correlationType`: The type for this correlation. For a complete list of correlation type identifiers, see doc://com.apple.healthkit/documentation/HealthKit/HKCorrelationTypeIdentifier.
- `startDate`: The start date for the sample. This date must be equal to or earlier than the end date; otherwise, this method throws an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException).
- `endDate`: The end date for the sample. This date must be equal to or later than the start date; otherwise, this method throws an exception (doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException).
- `objects`: A set of doc://com.apple.healthkit/documentation/HealthKit/HKSample objects. Specifically, this set contains the quantity and category samples to be grouped into this correlation.

## Return Value

Return Value A new correlation instance.

## Discussion

Discussion Use a correlation object to represent composite data—that is, a sample that requires more than a single value. To create a correlation sample, first create the quantity and category samples you intend to combine into the correlation. Next, create the correlation’s type. Finally, instantiate the correlation, passing in the type, start date, end date, and samples, as shown below. Use this method when you do not need to include additional metadata and the data was not recorded using external hardware.

## See Also

### Related Documentation

- [objects](healthkit/hkcorrelation/objects.md)
- [correlationType(forIdentifier:)](healthkit/hkobjecttype/correlationtype(foridentifier:).md)
- [endDate](healthkit/hksample/enddate.md)
- [correlationType](healthkit/hkcorrelation/correlationtype.md)
- [metadata](healthkit/hkobject/metadata.md)
- [startDate](healthkit/hksample/startdate.md)

### Creating Correlations

- [init(type:start:end:objects:metadata:)](healthkit/hkcorrelation/init(type:start:end:objects:metadata:).md)
- [init(type:start:end:objects:device:metadata:)](healthkit/hkcorrelation/init(type:start:end:objects:device:metadata:).md)
