I am trying to make pagination for my tableView
I added the condition for checking the last cell in indexPath, but it does not work in the following code
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == articles?.articles.count ?? 2 - 1 {
pageNumber += 1
catPass = PassUrl(categoryName: titleName ?? "", id: sourceId, searchText: labelText, pageInt: pageNumber)
APICall.shared.fetchData(category: catPass) { (response) in
DispatchQueue.main.async {
self.articles = response
self.myTableView.reloadData()
}
}
}
}
When I scroll down to the last cell, it does not load more.
How this func could be corrected?