<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKCorrelation/init(type:start:end:objects:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKCorrelation(cm)correlationWithType:startDate:endDate:objects:"
  },
  "title" : "init(type:start:end:objects:)"
}
-->

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

Instantiates and returns a new correlation instance.

```
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 [`HKCorrelationTypeIdentifier`](/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 [`HKSample`](/documentation/HealthKit/HKSample) objects. Specifically, this set contains the quantity and category samples to be grouped into this correlation.

## Return Value

A new correlation instance.

## 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.

```objc
NSDate *date = [NSDate date];
 
// Create systolic sample
 
HKQuantityType *systolicType =
[HKObjectType quantityTypeForIdentifier:
     HKQuantityTypeIdentifierBloodPressureSystolic];
 
HKQuantity *systolicQuantity =
[HKQuantity quantityWithUnit:[HKUnit millimeterOfMercuryUnit]
                 doubleValue:120.0];
 
HKQuantitySample *systolicSample =
[HKQuantitySample quantitySampleWithType:systolicType
                                quantity:systolicQuantity
                               startDate:date
                                 endDate:date];
 
// Create diastolic sample
 
HKQuantityType *diastolicType =
[HKObjectType quantityTypeForIdentifier:
    HKQuantityTypeIdentifierBloodPressureDiastolic];
 
HKQuantity *diastolicQuantity =
[HKQuantity quantityWithUnit:[HKUnit millimeterOfMercuryUnit]
                 doubleValue:75.0];
 
HKQuantitySample *diastolicSample =
[HKQuantitySample quantitySampleWithType:diastolicType
                                quantity:diastolicQuantity
                               startDate:date
                                 endDate:date];
 
// Create blood pressure sample
 
HKCorrelationType *bloodPressureType =
[HKObjectType correlationTypeForIdentifier:
    HKCorrelationTypeIdentifierBloodPressure];
 
NSSet *objects = [NSSet setWithObjects:systolicSample, diastolicSample, nil];
 
HKCorrelation *bloodPressure =
[HKCorrelation correlationWithType:bloodPressureType
                         startDate:date
                           endDate:date
                           objects:objects];
```

## See Also

[`objects`](/documentation/HealthKit/HKCorrelation/objects)

The set of sample objects that make up the correlation.

[`+  correlationTypeForIdentifier:`](/documentation/HealthKit/HKObjectType/correlationType(forIdentifier:))

Returns the shared correlation type for the provided identifier.

[`endDate`](/documentation/HealthKit/HKSample/endDate)

The sample’s end date.

[`correlationType`](/documentation/HealthKit/HKCorrelation/correlationType)

The type for this correlation.

[`metadata`](/documentation/HealthKit/HKObject/metadata)

The metadata for this HealthKit object.

[`startDate`](/documentation/HealthKit/HKSample/startDate)

The sample’s start date.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)