DataSourceProtocol

public protocol DataSourceProtocol

An instance conforming to DataSourceProtocol represents a sectioned data source of items to be displayed in either a collection view or table view.

Associated types

  • The type of items in the data source.

    Declaration

    Swift

    associatedtype Item

Methods

  • Declaration

    Swift

    func numberOfSections() -> Int

    Return Value

    The number of sections.

  • Declaration

    Swift

    func numberOfItems(inSection section: Int) -> Int

    Parameters

    section

    A section index in the data source.

    Return Value

    The number of items in the specified section.

  • Declaration

    Swift

    func items(inSection section: Int) -> [Item]?

    Parameters

    section

    A section in the data source.

    Return Value

    The items in the specified section.

  • Declaration

    Swift

    func item(atRow row: Int, inSection section: Int) -> Item?

    Parameters

    row

    A row in the data source.

    section

    A section in the data source.

    Return Value

    The item specified by the section and row, or nil.

  • Declaration

    Swift

    func headerTitle(inSection section: Int) -> String?

    Parameters

    section

    A section in the data source.

    Return Value

    The header title for the specified section.

  • Declaration

    Swift

    func footerTitle(inSection section: Int) -> String?

    Parameters

    section

    A section in the data source.

    Return Value

    The footer title for the specified section.

  • item(atIndexPath:) Extension method

    Declaration

    Swift

    public func item(atIndexPath indexPath: IndexPath) -> Item?

    Parameters

    indexPath

    An index path specifying a row and section in the data source.

    Return Value

    The item specified by indexPath, or nil.