Question

I have to fill a TableView with lots of items (20.000 items frol sqlite) but I know that I will overload it. Is there a way to load only the needed data when scolling ?

for example if I display 100 items when I scroll over 100 should I load 200 in the table or load only the items 101>200 ?

Also is it possible when returning the Cell content to fetch for EACH element in the embedded sqlite DB ?

Thanks

Was it helpful?

Solution

I have to fill a TableView with lots of items (20.000 items frol sqlite) but I know that I will overload it. Is there a way to load only the needed data when scrolling?

UITableView is designed specifically to load only the cells that are visible. You don't so much "fill" a table as you make the data available to the table via the table's data source. As the table scrolls, it asks its data source for additional cells, and it re-uses the cells that are no longer visible. This minimizes memory usage and maximizes speed. You don't need to do anything to achieve this other than implement the necessary table view data source and delegate methods in your view controller (or some other object).

Also is it possible when returning the Cell content to fetch for EACH element in the embedded sqlite DB ?

Sure, you can do that. Just implement your -tableView:cellForRowAtIndexPath: method to make the appropriate SQLite query for the requested cell.

OTHER TIPS

This the default functionality of a UITableView, it only draws the necessary rows when they need to appear. This is why you have "reusable cells" because they keep getting reused. I think storing the 20,000 items should not be terrible memory overhead, so I would just try using the UITableView default functionality and you will be fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top