Instance Method

insert(_:at:)

Adds a new quantity to the series at the provided date and time.

Declaration

func insert(_ quantity: HKQuantity, at date: Date) throws

Parameters

quantity

The quantity to insert.

date

The start date associated with the quantity. If this is the same start date as a previously provided quantity, this quantity replaces the previous one.

Fails with an HKError.Code.errorInvalidArgument error if the date parameter is earlier than the series builder’s startDate property.

Discussion

This method calls insert(_:for:), passing a date interval with the provided start date, and a duration of 0.

See Also

Adding Values

func insert(HKQuantity, for: DateInterval)

Adds a new quantity to the series with the provided date interval.