TableViewDriver
@objc
open class TableViewDriver : NSObject
A data source that drives the table views appereance and behavior based on an underlying
TableViewModel.
-
Communicates information for refreshing the table view.
See moreDeclaration
Swift
public enum TableRefreshContext -
The table view to which the
TableViewModelis rendered.Declaration
Swift
public let tableView: UITableView -
Describes the current UI state of the table view.
When this property is set, the UI of the related
UITableViewwill be updated. If not only the content of individual cells/sections has changed, but instead cells/sections were moved/inserted/deleted, the behavior of this setter depends on the value of theautomaticDiffingEnabledproperty.If
automaticDiffingEnabledis set totrue, and cells/sections have been moved/inserted/deleted, updating this property will result in the UI of the table view being updated automatically.If
automaticDiffingEnabledis set tofalse, and cells/sections have been moved/inserted/deleted, the caller must update theUITableViewstate manually, to bring it back in sync with the new model, e.g. by callingreloadData()on the table view.Declaration
Swift
public var tableViewModel: TableViewModel? { get set } -
The animation for row insertions.
Declaration
Swift
public var insertionAnimation: UITableView.RowAnimation -
The animation for row deletions.
Declaration
Swift
public var deletionAnimation: UITableView.RowAnimation -
Initializes a data source that drives a
UITableViewbased on aTableViewModel.Declaration
Swift
public init( tableView: UITableView, tableViewModel: TableViewModel? = nil, shouldDeselectUponSelection: Bool = true, automaticDiffingEnabled: Bool = true)Parameters
tableViewthe table view to which this data source will render its view models.
tableViewModelthe view model that describes the initial state of this table view.
shouldDeselectUponSelectionindicates if selected cells should immediately be deselected. Defaults to
true.automaticDiffingEnableddefines whether or not this data source updates the table view automatically when cells/sections are moved/inserted/deleted. Defaults to
true.
-
Updates all currently visible cells and sections, such that they reflect the latest state decribed in their respective view models. Typically this method should not be called directly, as it is called automatically whenever the
tableViewModelproperty is updated.Declaration
Swift
public func refreshViews(refreshContext: TableRefreshContext = .unknown)
View on GitHub
TableViewDriver Class Reference