Displaying large amounts of data from Core Data

I have such a task before me: the database contains more than 10,000 records, I need to display them in the form of a table, but I cannot take all 10,000 and store them in an array, how to organize the work, for example, when scrolling through 100 records in the form of a table ... Load the next 100 records from the database.

I found things like fetchLimit and fetchOffset, but I still haven't figured out how to use them for my task.

What would you tell me?

+3


source to share


1 answer


I believe that if you are using Core Data and need it UITableView

, you should use it demonstratively NSFetched​Results​Controller

.

From Apple documentation.

You use the Result Checker to efficiently manage the results returned from the Master Data Fetch query to provide data for the UITable View object.



Using this approach, you will be using the default cache, which will improve performance. In addition, you will dynamically update UITableView

when some records in Core Data are changed or added.

Also to retrieve data in parts, you can change NSFetchRequest

and set fetchLimit

for each request.

An example of a simple implementation NSFetched​Results​Controller

.

+3


source







All Articles