Instance Method

tableView(_:cellForRowAt:)

Asks the data source for a cell to insert in a particular location of the table view.

Required.

Declaration

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

Parameters

tableView

A table-view object requesting the cell.

indexPath

An index path locating a row in tableView.

Return Value

An object inheriting from UITableViewCell that the table view can use for the specified row. An assertion is raised if you return nil.

Discussion

The returned UITableViewCell object is frequently one that the application reuses for performance reasons. You should fetch a previously created cell object that is marked for reuse by sending a dequeueReusableCell(withIdentifier:) message to tableView. Various attributes of a table cell are set automatically based on whether the cell is a separator and on information the data source provides, such as for accessory views and editing controls.

See Also

Configuring a Table View

func numberOfSections(in: UITableView)

Asks the data source to return the number of sections in the table view.

func tableView(UITableView, numberOfRowsInSection: Int)

Tells the data source to return the number of rows in a given section of a table view.

Required.

func tableView(UITableView, titleForHeaderInSection: Int)

Asks the data source for the title of the header of the specified section of the table view.

func tableView(UITableView, titleForFooterInSection: Int)

Asks the data source for the title of the footer of the specified section of the table view.