What is UITableView datasource protocol?


In the book. the author writes -

“The above two methods are part of UITableView’s data source protocol.”

and points to the code below, can any one please explain what is the UITableView here ? is it. the UITableViewController or the UITableView mentioned inside tableView methods, and what is the data source here, also what exactly is UITableView and is it a property of delegate, how does it get a datasource protocol , where is the author calling it in the given code , I am really sorry but every thing is very confusing and not told clearly by author , thanks

“// MARK:- Table View Data Source
override func tableView(_ tableView: UITableView,
      numberOfRowsInSection section: Int) -> Int {
  return 1

override func tableView(_ tableView: UITableView, 
             cellForRowAt indexPath: IndexPath) -> 
             UITableViewCell {
  let cell = tableView.dequeueReusableCell”

                        withIdentifier: "ChecklistItem", 
                                   for: indexPath)
  return cell

@amitsrivastava The table view’s data source sets the number of rows in each section and gets the cell for each row.

1 Like

This topic was automatically closed after 166 days. New replies are no longer allowed.