Reputation: 1081
How can I create live UITableView under iOS ?
I meen, I want to create application which connect to server written in JAVA. Server under POST request return table of maps with data (JSON format). The problem is that, the data could be very large (around 100000 recods). I already implemented on server side returning data in parts (when POST have offset and size params, server returns data from offset to (offset + size) and total count of data).
The problem is that i don't have any idea how can I implement it with iOS.
I know how can I made UITableView working with data downloaded from server, but I don't know how can I made UITableView working with parts of data: something like: on enter to view I download only 100 rows form 100000, when user scrolls down (for example to 80 row) I download next part of data. I mean I don't want to store whole 100000 rows in memory, but only 200 rows which can be displayed in table view. When user scrolls to end of table, in memmory I shoud have rows from 99800 to 100000
Upvotes: 0
Views: 234
Reputation: 2251
When user scroll the tableview
we'll check if the last cell is reached or not if the last cell is reached we'll download the next dataset
like this :
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger sectionsAmount = [tableView numberOfSections];
NSInteger rowsAmount = [tableView numberOfRowsInSection:[indexPath section]];
if ([indexPath section] == sectionsAmount - 1 && [indexPath row] == rowsAmount - 1) {
// This is the last cell in the table
//Here you can download the next part of dataset and reload the tableView.
}
}
Hope this will help you.
Upvotes: 1