ORKAnswerFormat Class Reference
Inherits from | NSObject |
---|---|
Conforms to | NSCopying NSSecureCoding |
Declared in | ORKAnswerFormat.h |
The ORKAnswerFormat
class is the abstract base class for classes that describe the
format in which a survey question or form item should be answered. The ResearchKit framework uses
ORKQuestionStep
and ORKFormItem
to represent questions to ask the user. Each
question must have an associated answer format.
To use an answer format, instantiate the appropriate answer format subclass and attach it to a question step or form item. Incorporate the resulting step into a task, and present the task with a task view controller.
An answer format is validated when its owning step is validated.
Some answer formats are constructed of other answer formats. When this is the
case, the answer format can override the method impliedAnswerFormat
to return
the answer format that is implied. 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.
Properties
questionType
The type of question. (read-only)
@property (readonly) 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
Validation
– validateParameters
Validates the parameters of the answer format to ensure that they can be displayed.
- (void)validateParameters
Discussion
Typically, this method is called by the validation methods of the owning objects, which are themselves called when a step view controller that contains this answer format is about to be displayed.
Declared In
ORKAnswerFormat.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