DataSource

public struct DataSource<Item>
extension DataSource: DataSourceProtocol

A DataSource is a concrete DataSourceProtocol. It represents a collection of section-based data.

Properties

  • The sections in the data source.

    Declaration

    Swift

    public var sections: [Section<Item>]

Initialization

  • Constructs a new DataSource.

    Declaration

    Swift

    public init(_ sections: [Section<Item>])

    Parameters

    sections

    The sections for the data source.

  • Constructs a new DataSource.

    Declaration

    Swift

    public init(sections: Section<Item>...)

    Parameters

    sections

    The sections for the data source.

Methods

  • Inserts the item at the specified index path.

    Declaration

    Swift

    public mutating func insert(item: Item, at indexPath: IndexPath)

    Parameters

    item

    The item to be inserted.

    indexPath

    The index path specifying the location for the item.

  • Inserts the item at the specified row and section.

    Declaration

    Swift

    public mutating func insert(item: Item, atRow row: Int, inSection section: Int)

    Parameters

    item

    The item to be inserted.

    row

    The row location for the item.

    section

    The section location for the item.

  • Appends the item at the specified section.

    Declaration

    Swift

    public mutating func append(_ item: Item, inSection section: Int)

    Parameters

    item

    The item to be appended.

    section

    The section location for the item.

  • Removes the item at the specified row and section.

    Declaration

    Swift

    @discardableResult
    public mutating func remove(atRow row: Int, inSection section: Int) -> Item?

    Parameters

    row

    The row location of the item.

    section

    The section location of the item.

    Return Value

    The item removed, or nil if it does not exist.

  • Removes the item at the specified index path.

    Declaration

    Swift

    @discardableResult
    public mutating func remove(at indexPath: IndexPath) -> Item?

    Parameters

    indexPath

    The index path specifying the location of the item.

    Return Value

    The item at indexPath, or nil if it does not exist.

Subscripts

  • Declaration

    Swift

    public subscript(index: Int) -> Section<Item> { get set }

    Parameters

    index

    The index of a section.

    Return Value

    The section at index.

  • Declaration

    Swift

    public subscript(indexPath: IndexPath) -> Item { get set }

    Parameters

    indexPath

    The index path of an item.

    Return Value

    The item at indexPath.