My table view cells aren't showing the date of json files collected from NewsApi.com. Can someone pls help ? Link to project below Link to project below. In in the LatestNewsViewController
https://github.com/lexypaul13/Covid-News
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) as! NewsTableViewCell
cell.authorName.text = articles?[indexPath.row].author
cell.headLine.text = articles?[indexPath.row].title
cell.newsImage.downloadImage(from:(self.articles?[indexPath.item].urlImage ?? "nill"))
if let date = articles?[indexPath.row].publishedAt{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
guard let time = dateFormatter.date(from: date) else { return cell }
let formattedString = dateFormatter.string(from:time)
cell.timePublication.text = formattedString
}
return cell
}
https://github.com/lexypaul13/Covid-News
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) as! NewsTableViewCell
cell.authorName.text = articles?[indexPath.row].author
cell.headLine.text = articles?[indexPath.row].title
cell.newsImage.downloadImage(from:(self.articles?[indexPath.item].urlImage ?? "nill"))
if let date = articles?[indexPath.row].publishedAt{
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
guard let time = dateFormatter.date(from: date) else { return cell }
let formattedString = dateFormatter.string(from:time)
cell.timePublication.text = formattedString
}
return cell
}