Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Building a Client App From Scratch (UITableViewDataSource v2)
extension ViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let tableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NewsTableViewCell
let article = articles[indexPath.row]
tableViewCell.titleLabel.text = article.title
tableViewCell.contentLabel.text = article.content
if let urlToImage = article.urlToImage {
tableViewCell.isHidden = false
tableViewCell.thumbnailView.load(url: urlToImage)
} else {
tableViewCell.isHidden = true
return tableViewCell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment