QuestionnaireController

open class QuestionnaireController: NSObject, ORKTaskViewControllerDelegate

Instances of this class can prepare questionnaires and get a callback when preparation has finished.

Use prepareQuestionnaireViewController(), which fulfills any questionnaire dependencies before calling the callback, in which you get a handle to a ORKTaskViewController view controller that you can present on the UI.

The whenCompleted callback is called when the user completes the questionnaire without cancelling nor error and provides the responses in a QuestionnaireResponse resource. The whenCancelledOrFailed callback is called when the questionnaire is cancelled (error = nil) or finishes with an error.

See Questionnaire/README.md for detailed instructions.

  • The questionnaire the controller represents.

    Declaration

    Swift

    public final var questionnaire: Questionnaire?
  • Callback called when the user finishes the questionnaire without error.

    Declaration

    Swift

    public final var whenCompleted: ((_ viewController: ORKTaskViewController, _ answers: QuestionnaireResponse?) -> Void)?
  • Callback to be called when the questionnaire is cancelled (Error = nil) or finishes with an error.

    Declaration

    Swift

    public final var whenCancelledOrFailed: ((ORKTaskViewController, Error?) -> Void)?
  • The logger to use, if any.

    Declaration

    Swift

    open var logger: OAuth2Logger?
  • Designated initializer.

    Declaration

    Swift

    public init(questionnaire: Questionnaire)

    Parameters

    questionnaire

    The Questionnaire the receiver should handle

  • Attempts to fulfill the promise, calling the callback when done.

    Declaration

    Swift

    open func prepareQuestionnaireViewController(callback: @escaping ((ORKTaskViewController?, Error?) -> Void))

    Parameters

    callback

    Callback to be called on the main queue, either with a task view controller prepared for the questionnaire task or an error