I have such a task in front of me: there are more than 10,000 records in the database, I need to display them in the table view, but I can not take all 10,000 and store in the array how to organize the work, for example, when scrolling 100 records in a table view, Download the next 100 entries from the database.
I found things like fetchLimit and fetchOffset, but I still did not understand how to use them for my task.
What would you tell me?
I believe if you are using Core Data and you need UITableView you should defiantly use NSFetchedResultsController.
From Apple documentation.
You use a fetched results controller to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object.
By using of this approach you going to use by default Cache that will improve performance. Also with this you going to dynamically update UITableView when some of the records in Core Data will be changed or be added.
Also to fetch data by portion you can modify NSFetchRequest and setfetchLimit for each request.
Example of the simple NSFetchedResultsController implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With