Endless UITableview Section

I have a tabular view with one section. I pull data from the Internet in small chunks asynchronously in the background. I have a problem, I do not know how many records will be in total. When the web service stops returning data, I know that I have all of them, in some cases the lines can be infinite.

Method:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 

for obvious reasons, it is called once at the beginning of the download, at the moment I do not know how big my section will be. Any ideas on how best to approach this issue? Can I set the partition size anywhere after calling this method?

+4
source share
2 answers

You can make tableview reload its data, call

 [tableView reloadData]; 

... and again he will ask the data source about the number of rows, etc.

+8
source

You say that data is pulled into chunks - so just refresh the table in chunks.

Each time a piece is loaded, reload the table. That way, you know how many lines after each piece are completed.

Example:

  • Download application (no data)
  • Download Fragments
    • Put results in an array
    • 6 rows in the array, return [array count] in the number of rows in the section method
    • reload table
  • repeat step 2 until complete.

Refresh data does not reset the scroll position.

0
source

All Articles