The UITable
protocol is adopted by an object that mediates the application’s data model for a UITable
object. The data source provides the table-view object with the information it needs to construct and modify a table view.
SDKs
- iOS 2.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
protocol UITableViewDataSource
Overview
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 UITable
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 UITable
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.
Note
To enable the swipe-to-delete feature of table views (wherein a user swipes horizontally across a row to display a Delete button), you must implement the table
method.
Many methods take NSIndex
objects as parameters. UITable
declares a category on NSIndex
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:
class method). (The first index in each index path identifies the section and the next identifies the row.)