Created
February 16, 2020 20:03
-
-
Save yzhong52/3f1497d7c58c7b1b0d97236b1e0d39ba to your computer and use it in GitHub Desktop.
Building a Client App From Scratch (UITableViewDataSource v2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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