HostCell

public struct HostCell<View, State, Layout> : CellConfigType where View : UIView, State : Equatable, Layout : TableItemLayout

Defines the view, state and layout information of a row item inside a TableSection. It relies on you to build UIView subclasses and use those instead of implementing UITableViewCell or UICollectionViewCell subclasses. This has the side effect of building better more reusable view components. This greatly simplifies composition by combining several host-cells into more complex layouts. It also makes equality simpler and more Swifty by requiring that anything provided as State only requires that the State object conform to the Equatable protocol. The View portion of the generic only requires it to be a UIView subclass.

  • key

    Declaration

    Swift

    public let key: String
  • Declaration

    Swift

    public var style: CellStyle?
  • Declaration

    Swift

    public let actions: CellActions
  • Contains the state information of a cell.

    Declaration

    Swift

    public let state: State
  • A function that updates a cell’s view to match the current state. It receives two values, the view instance and an optional state instance. The purpose of this function is to update the view to reflect that of the given state. The reason that the state is optional is because cells may move into the reuse queue. When this happens they no longer have a state and the updater function is called giving the opportunity to reset the view to its default value.

    Declaration

    Swift

    public let cellUpdater: (_ view: View, _ state: State?) -> Void
  • Registers the instance of this HostCell for use in creating new table cells.

    Declaration

    Swift

    public func register(with tableView: UITableView)

    Parameters

    tableView

    the UITableView to register the cell with.

  • Registers the instance of this HostCell for use in creating new table cells.

    Declaration

    Swift

    public func register(with collectionView: UICollectionView)

    Parameters

    collectionView

    the UICollectionView to register the cell with.

  • Returns a reusable UITableView cell object for the specified reuse identifier and adds it to the table.

    Declaration

    Swift

    public func dequeueCell(from tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell

    Parameters

    tableView

    the UITableView holding the cells.

    indexPath

    The index path specifying the location of the cell.

    Return Value

    A UITableViewCell object that exists in the reusable-cell queue.

  • Returns a reusable UICollectionView cell object for the specified reuse identifier and adds it to the collection.

    Declaration

    Swift

    public func dequeueCell(from collectionView: UICollectionView, at indexPath: IndexPath) -> UICollectionViewCell

    Parameters

    collectionView

    the UICollectionView holding the cells.

    indexPath

    The index path specifying the location of the cell.

    Return Value

    A UICollectionViewCell object that exists in the reusable-cell queue.