I have UITableView
with display caching data from array
I want to make pagination on UITableView
like this structure:
1)When I go to view with UITableView
- it's show me all caching data (this I did and it's works)
2) When user scroll down and if caching data left 5
call function whitch load new 10 data to array and show at the botom in UITableView
and add recheck( when when table rows show 15 of 20 rows call function to load more data and add)
For example : in cach array I have 10 data, function load new and in table shows me 20 rows with data
I try to do this:
public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
print(indexPath.row)
let lastItem = array.count - 1
if indexPath.row == lastItem {
loadMoreData()
}
}
func loadMoreData {
for _ in 0...9 {
//load data from server
}
tableView.reloadData()
}