I have a UITableView that has about 30 items. Here's an overview of how my tableview works: In order to enable infinite scrolling and a small memory size, I calculate the scrolling direction, speed, and I remove the top 10 items and add 10 items to the bottom (the same goes for scrolling up the other way). If I were to scroll to an item, the indexPath.row stays at that same item when I attempt to reloadData() with a new set of 30 items.
I have tried creating my own index to use, but it has a lot facets to it that would make it pretty complicated. I'm looking to see if I can just reset indexPath.row.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
item = items[indexPath.row]
}
Sometimes, I would like to jump to another set of items that is a few pages down. So, I then replace the current array of items with a new 30 items. However, when I have already scrolled down a little (let's say I'm on the 15th cell), and I then jump to a new set of 30 items, the very first cell to show in tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell is the 15th cell. indexPath.row = 15... Why is indexPath.row not updating to 0? Is there a way to reset indexPath.row to 0 when I fill my array with a new set of items and call reloadData()?