Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear NSFetchedResultsController?

If I perform a fetch w/ a NSFetchedResultsController that returns objects and then want to clear the controller, i.e., have .fetchedObjects be an empty array, is there a method that can be called or do I have to perform another fetch that does not return any results?

like image 672
ChrisP Avatar asked Dec 06 '12 21:12

ChrisP


1 Answers

You could set the fetch request of your fetched results controller to return nothing:

self.fetchedResultsController.fetchRequest.predicate = 
   [NSPredicate  predicateWithValue:NO];
[self.fetchedResultsController performFetch:nil]

Now self.fetchedResultsController.fetchedObjects should return an empty array.

like image 50
Mundi Avatar answered Nov 27 '22 18:11

Mundi