Skip to content

UIKit ListsOfState Case Study: Why the local dataSource var in the ViewController? #351

Answered by mbrandonw
ryanbooker asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ryanbooker, the dataSource variable is what powers the UITableViewDataSource conformance. For example, it determines the number of rows in the table view:

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
self.dataSource.count
}

And the label for the cell at a particular row:

cell.textLabel?.text = "\(self.dataSource[indexPath.row].count)"

To me it seems necessary to implement th…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
3 replies
@ryanbooker
Comment options

@mbrandonw
Comment options

@stephencelis
Comment options

Answer selected by ryanbooker
Comment options

You must be logged in to vote
2 replies
@mbrandonw
Comment options

@mluisbrown
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants