ORKHealthKitQuantityTypeAnswerFormat Class Reference

Inherits from ORKAnswerFormat : NSObject
Declared in ORKHealthAnswerFormat.h
ORKHealthAnswerFormat.m

Overview

The ORKHealthKitQuantityTypeAnswerFormat class represents an answer format that lets participants enter values that correspond to a HealthKit quantity type, such as systolic blood pressure.

The actual UI used for collecting data with this answer format depends on the HealthKit type being collected. The default value in the UI is the most recent value received from HealthKit, if such a value exists. When a step or item is presented using this answer format, authorization is requested unless the property shouldRequestAuthorization is set to NO.

You can use the HealthKit quantity type answer format to let users autofill values such as their weight with the most recent data from HealthKit.

Other Methods

– questionType

The type of question. (read-only)

- (ORKQuestionType)questionType

Discussion

You can use this enumerated value in your Objective-C code to switch on a rough approximation of the type of question that is being asked.

Note that answer format subclasses override the getter to return the appropriate question type.

Declared In

ORKAnswerFormat.h

+ answerFormatWithQuantityType:unit:style:

Returns a new HealthKit quantity answer format with the specified quantity type.

+ (instancetype)answerFormatWithQuantityType:(HKQuantityType *)quantityType unit:(HKUnit *)unit style:(ORKNumericAnswerStyle)style

Parameters

quantityType

The HealthKit quantity type to collect.

unit

The unit used to describe the quantity. If the value of this parameter is nil, the default HealthKit unit is used, when available.

style

The numeric answer style to use when collecting this value.

Return Value

A HealthKit quantity answer format instance.

Declared In

ORKHealthAnswerFormat.h

– initWithQuantityType:unit:style:

Returns an initialized HealthKit quantity answer format using the specified quantity type, unit, and numeric answer style.

- (instancetype)initWithQuantityType:(HKQuantityType *)quantityType unit:(HKUnit *)unit style:(ORKNumericAnswerStyle)style

Parameters

quantityType

The HealthKit quantity type to collect.

unit

The unit used to describe the quantity. If the value of this parameter is nil, the default HealthKit unit is used, when available.

style

The numeric answer style to use when collecting this value.

Return Value

An initialized HealthKit quantity answer format.

Discussion

This method is the designated initializer.

Declared In

ORKHealthAnswerFormat.h

– impliedAnswerFormat

Some answer formats are constructed of other answer formats. This method allows a subclass to return a different answer format for use in defining the UI/UX for the answer format type. For example, a Boolean answer format is presented in the same way as a single-choice answer format with the choices Yes and No mapping to @(YES) and @(NO), respectively, so its impliedAnswerFormat is an ORKTextChoiceAnswerFormat with those options.

- (ORKAnswerFormat *)impliedAnswerFormat

Declared In

ORKAnswerFormat.h

Other Methods

  shouldRequestAuthorization

Should authorization be requested for the associated HealthKit data type. Default = YES.

@property (nonatomic) BOOL shouldRequestAuthorization

Declared In

ORKHealthAnswerFormat.h

  quantityType

The HealthKit quantity type to collect. (read-only)

@property (nonatomic, copy, readonly) HKQuantityType *quantityType

Declared In

ORKHealthAnswerFormat.h

  unit

The HealthKit unit in which to collect the answer. (read-only)

@property (nonatomic, strong, readonly, nullable) HKUnit *unit

Discussion

The unit is displayed when the user is entering data, and is also included in the question result generated by form items or question steps that use this answer format.

Declared In

ORKHealthAnswerFormat.h

  numericAnswerStyle

The numeric answer style. (read-only)

@property (nonatomic, readonly) ORKNumericAnswerStyle numericAnswerStyle

Declared In

ORKHealthAnswerFormat.h