custom table view cell in swift code example
Example: write into table view swift 5
import UIKit
class ToDoListViewController: UITableViewController {
let itemArray = ["Study Swift", "Buy Eggs", "Read a newspapper"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemArray.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ToDoListCell", for: indexPath)
cell.textLabel?.text = itemArray[indexPath.row]
return cell
}
}