UITableViewDataSource protocol is adopted by an object that mediates the application’s data model for a
UITableView object. The data source provides the table-view object with the information it needs to construct and modify a table view.
- iOS 8.0+
- tvOS 9.0+
As a representative of the data model, the data source supplies minimal information about the table view’s appearance. The table-view object’s delegate—an object adopting the
UITableViewDelegate protocol—provides that information.
The required methods of the protocol provide the cells to be displayed by the table-view as well as inform the
UITableView object about the number of sections and the number of rows in each section. The data source may implement optional methods to configure various aspects of the table view and to insert, delete, and reorder rows.
Many methods take
NSIndexPath objects as parameters.
UITableView declares a category on
NSIndexPath that enables you to get the represented row index (
row property) and section index (
section property), and to construct an index path from a given row index and section index (
init(row:section:) class method). (The first index in each index path identifies the section and the next identifies the row.)