RSDFormStepDataSourceObject

open class RSDFormStepDataSourceObject : RSDStepViewModel, RSDTableDataSource

RSDFormStepDataSourceObject is a concrete implementation of the RSDTableDataSource protocol that is designed to be used to supply the data source for a form step. This class inherits from RSDStepViewModel to allow the table view controller to use this class as its stepViewModel.

  • The delegate associated with this data source.

    Declaration

    Swift

    open weak var delegate: RSDTableDataSourceDelegate?
  • The UI hints supported by this data source.

    Declaration

    Swift

    public let supportedHints: Set<RSDFormUIHint>
  • The table sections for this data source.

    Declaration

    Swift

    open private(set) var sections: [RSDTableSection] {
      get
      }
  • The table item groups displayed in this table.

    Declaration

    Swift

    open private(set) var itemGroups: [RSDTableItemGroup] {
      get
      }
  • The initial result when the data source was first displayed.

    Declaration

    Swift

    open private(set) var initialResult: RSDCollectionResult? {
      get
      }
  • Initialize a new RSDFormStepDataSourceObject.

    Declaration

    Swift

    public init(step: RSDStep, parent: RSDPathComponent?, supportedHints: Set<RSDFormUIHint>? = nil)

    Parameters

    step

    The RSDStep for this data source.

    taskViewModel

    The current task path for this data source.

    supportedHints

    The supported UI hints for this data source.

  • Specifies whether the next button should be enabled based on the validity of the answers for all form items.

    Declaration

    Swift

    override open var isForwardEnabled: Bool { get }
  • The collection result associated with this data source. The default implementation is to search the taskViewModel for a matching result and if that fails to return a new instance created using instantiateCollectionResult().

    Declaration

    Swift

    open func collectionResult() -> RSDCollectionResult

    Return Value

    The appropriate collection result.

  • Instantiate a collection result of the appropriate object type for this data source. The default implementation returns a new instance of RSDCollectionResultObject.

    Declaration

    Swift

    open func instantiateCollectionResult() -> RSDCollectionResult

    Return Value

    The appropriate collection result.

  • Instantiate the appropriate answer result for the given item group.

    Declaration

    Swift

    open func instantiateAnswerResult(for itemGroup: RSDInputFieldTableItemGroup) -> RSDAnswerResult?

    Parameters

    itemGroup

    The item group for which to create a result.

    Return Value

    The answer result (if any).

  • Retrieve the RSDTableItemGroup with a specific RSDInputField identifier.

    Declaration

    Swift

    open func itemGroup(with identifier: String) -> RSDTableItemGroup?

    Parameters

    identifier

    The identifier of the RSDInputField assigned to the item group.

    Return Value

    The requested RSDTableItemGroup, or nil if it cannot be found.

  • Retrieve the ‘RSDTableItemGroup’ for a specific IndexPath.

    Declaration

    Swift

    open func itemGroup(at indexPath: IndexPath) -> RSDTableItemGroup?

    Parameters

    indexPath

    The index path that represents the item group in the table view.

    Return Value

    The requested RSDTableItemGroup, or nil if it cannot be found.

  • Save an answer for a specific IndexPath.

    Throws

    RSDInputFieldError if the answer is invalid.

    Declaration

    Swift

    open func saveAnswer(_ answer: Any, at indexPath: IndexPath) throws

    Parameters

    answer

    The object to be save as the answer.

    indexPath

    The IndexPath that represents the RSDTableItem in the table view.

  • Select or deselect the answer option for a specific IndexPath.

    Throws

    RSDInputFieldError if the selection is invalid.

    Declaration

    Swift

    open func selectAnswer(item: RSDTableItem, at indexPath: IndexPath) throws -> (isSelected: Bool, reloadSection: Bool)

    Parameters

    indexPath

    The IndexPath that represents the RSDTableItem in the table view.

    Return Value

    • isSelected: The new selection state of the selected item.
    • reloadSection: true if the section needs to be reloaded b/c other answers have changed, otherwise returns false.

  • Determine if all answers are valid. Also checks the case where answers are required but one has not been provided.

    Declaration

    Swift

    open func allAnswersValid() -> Bool

    Return Value

    A Bool indicating if all answers are valid.

  • Convenience method for building the sections of the table from the input fields.

    Declaration

    Swift

    open func buildSections() -> ([RSDTableSection], [RSDTableItemGroup])

    Return Value

    The sections for the table.

  • Instantiate the appropriate item group for this input field.

    Declaration

    Swift

    open func instantiateTableItemGroup(for inputField: RSDInputField, beginningRowIndex: Int) -> RSDTableItemGroup

    Parameters

    inputField

    The input field to convert to an item group.

    beginningRowIndex

    The beginning row index for this item group.

    Return Value

    The instantiated item group.

  • What is the preferred ui hint for this input field that is supported by this table? By default, this will look for the uiHint from the inputField to be included in the supported hints and if not, will return the preferred ui hint for the data type.

    Declaration

    Swift

    open func preferredUIHint(for inputField: RSDInputField) -> RSDFormUIHint

    Return Value

    The ui hint to return.

  • Convenience method for looking at the previous results in the task path and setting the answer based on that result. Get the collection result for this step and populate that result with the initial results that are valid from this form.

    Note

    This is not handled universally by the RSDTaskController for all steps because it is possible that a different implementation should not include populating the current result with a previous result. For example, a form should be populated with previous answers, but an active test should not.

    Declaration

    Swift

    open func populateInitialResults()