Harper Creek
Harper Creek

Reputation: 437

Specifically changing one cell within a tableview populated with array elements

If I have a tableview that is populated with elements from an array but I want the first cell to be some specific element not within the array if some variable equals whatever, and then have the array populate the rest of the cells after it, how do i go about doing that?

Upvotes: 0

Views: 36

Answers (1)

Patroclus
Patroclus

Reputation: 1232

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

https://developer.apple.com/documentation/uikit/uitableviewdatasource/1614861-tableview

Using an if statement, return a different cell when row == 0 then return cells reflecting the array afterward.

Upvotes: 1

Related Questions