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
stepThe RSDStep for this data source.
taskViewModelThe current task path for this data source.
supportedHintsThe 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
taskViewModelfor a matching result and if that fails to return a new instance created usinginstantiateCollectionResult().Declaration
Swift
open func collectionResult() -> RSDCollectionResultReturn 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() -> RSDCollectionResultReturn 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
itemGroupThe item group for which to create a result.
Return Value
The answer result (if any).
-
Retrieve the
RSDTableItemGroupwith a specificRSDInputFieldidentifier.Declaration
Swift
open func itemGroup(with identifier: String) -> RSDTableItemGroup?Parameters
identifierThe identifier of the
RSDInputFieldassigned 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
indexPathThe 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
RSDInputFieldErrorif the answer is invalid.Declaration
Swift
open func saveAnswer(_ answer: Any, at indexPath: IndexPath) throwsParameters
answerThe object to be save as the answer.
indexPathThe
IndexPaththat represents theRSDTableItemin the table view. -
Select or deselect the answer option for a specific IndexPath.
Throws
RSDInputFieldErrorif the selection is invalid.Declaration
Swift
open func selectAnswer(item: RSDTableItem, at indexPath: IndexPath) throws -> (isSelected: Bool, reloadSection: Bool)Parameters
indexPathThe
IndexPaththat represents theRSDTableItemin the table view.Return Value
- isSelected: The new selection state of the selected item.
- reloadSection:
trueif the section needs to be reloaded b/c other answers have changed, otherwise returnsfalse.
-
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() -> BoolReturn Value
A
Boolindicating 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) -> RSDTableItemGroupParameters
inputFieldThe input field to convert to an item group.
beginningRowIndexThe 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) -> RSDFormUIHintReturn 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 theRSDTaskControllerfor 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()
View on GitHub
RSDFormStepDataSourceObject Class Reference