I have a TableViewController and the news is displayed there. I need every when the scrolling reaches the end to download news from the API with pagination.
First I upload the https://****.**/api/posts which equals page 1.
Then I need to load page 2 like this: https://****.**/api/posts?page=2
How to change the page number each time?
let downloader = Downloader() var page = 2 override func scrollViewDidScroll(_ scrollView: UIScrollView) { let url = "https://****.**/api/posts?page=\(page))" if (scrollView.contentOffset.y > self.lastOffsetY) { downloader.getLastestNews(url) } } override func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { lastOffsetY = scrollView.contentOffset.y }