For my app I am using a \"load more at bottom\" property as below. It works fine actually; the only problem is that when a user reaches the buttom, while the load more function
- Swift 3 , Xcode 8
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let lastElement = dataSource.count - 1
if !loadingData && indexPath.row == lastElement {
spinner.startAnimating()
loadingData = true
loadMoreData()
}
}
as per @vacawama async call in swift 3:-
func loadMoreData() {
DispatchQueue.global(qos: .background).async {
// this runs on the background queue
// here the query starts to add new 10 rows of data to arrays
DispatchQueue.main.async {
// this runs on the main queue
self.spinner.stopAnimating()
self.loadingData = false
}
}
}