Search code examples
iosxcodeuitableviewnsindexpath

How to create indexpaths for all rows and all sections for uitableview?


I have a table with n sections. Each section contains one row. How to create the index path for the table? There is a method that allows to create index path for all visible rows [self.tableView indexPathsForVisibleRows] I need something similar like indexPathsForAllRows

I need all this to update only the data in the table, because method [self.tableView reloadData]; updates all the table with headers and footers. That's why i have to use reloadRowsAtIndexPaths


Solution

  • You don't need reload all the rows. You only need to reload the visible cells (that is why indexPathsForVisibleRows exists).

    The cells that are off-screen will get their new data in cellForRowAtIndexPath: once they become visible.