Limit the results of NSFetchedResultsController and get more

HI Everything

I currently have an NSFetchedResultsController setting that returns all rows in a table in my main database. Then it fills my UITableView. The trouble is that it will quickly get out of hand when the rows grow in quantity.

How can I limit the original query to say 20 results and then add a button somewhere in the “Get More” button, where are we from?

Thanks for any guidance, as always.

+3
source share
4 answers

NSFetchRequest - setFetchLimit: - setFetchOffSet.

, NSFetchedResultsController , NSFetchedResultsController. , , ( w/new fetch request) , , /.

Apple bugreporter.apple.com, , .

+3

, :

fetchRequest NSFetchedResultsController, , , , .

:

[yourFetchedResultsController.fetchRequest setFetchLimit:50];
[NSFetchedResultsController deleteCacheWithName:"you cache name"];
[yourFetchedResultsController performFetch:nil];
+3

fetchBatchSize , . , . batchSize, fetchLimit offset, "", .

, , - NSFetchedResultsController, , . , .

+1

I believe that instead of setting -setFetchLimit and restricting your NSFetchRequest (for new lines you need to create a new reqeust), set -fetchBatchSize to control only the number of lines that are loaded into memory. Say: if you show 10 cells per view, set the batch size to double or so. As you scroll through your view, the controller will automatically load the new set into memory.

0
source

Source: https://habr.com/ru/post/1762346/


All Articles