HealthSampleMeasurement

public struct HealthSampleMeasurement<MeasurementType> where MeasurementType : HealthMeasurementType
extension HealthSampleMeasurement: Encodable

A value that can be logged to the Health app.

See

See Also: LogHealthSample
  • The size of the Health sample, represented as Text.

    Declaration

    Swift

    public var magnitude: Text
  • The unit of the Health sample.

    Declaration

    Swift

    public var unit: HealthSampleUnit<MeasurementType>
  • Initializes the value.

    Declaration

    Swift

    public init(magnitude: Text, unit: HealthSampleUnit<MeasurementType>)

    Parameters

    magnitude

    The size of the health sample.

    unit

    The unit of the health sample.

  • Initializes the value.

    Declaration

    Swift

    public init(magnitude: Variable, unit: HealthSampleUnit<MeasurementType>)

    Parameters

    magnitude

    The size of the health sample, as a Variable.

    unit

    The unit of the health sample.

  • Encodes this value into the given encoder.

    Throws

    This function throws an error if any values are invalid for the given encoder’s format.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to write data to.