The methods adopted by the object you use to manage data and provide cells for a table view.
- iOS 2.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Table views manage only the presentation of their data; they do not manage the data itself. To manage the data, you provide the table with a data source object—that is, an object that implements the
UITable protocol. A data source object responds to data-related requests from the table. It also manages the table's data directly, or coordinates with other parts of your app to manage that data. Other responsibilities of the data source object include:
Reporting the number of sections and rows in the table.
Providing cells for each row of the table.
Providing titles for section headers and footers.
Configuring the table's index, if any.
Responding to user- or table-initiated updates that require changes to the underlying data.
Only two methods of this protocol are required, and they are shown in the following example code.
Use other methods of this protocol to enable specific features for your table. For example, you must implement the
table method to enable the swipe-to-delete feature for rows.
For information about how to create and configure your table's cells using your data source object, see Filling a Table with Data.
Specifying the Location of Rows and Sections
Table views communicate the location of cells to you using the
section properties of
NSIndex objects. Row and section indexes are zero based, so the first section is at index
0, the second at index
1, and so on. Similarly, the first row of each section is at index
0, which means you need both the
row values to identify a row uniquely. If your table has no sections, you need only the