From apple doc Modifying the Fetch Request I see that is possible to change the NSFetchRequest for NSFetchedResultsController. Steps are easy to set up.
After invoking performFetch: I think there is the need to call reloadData on the the table view. How to perform such call?
Reading some stackoverflow topics, I’ve seen that calling that method should work in most cases. But is there a right way to do it?
In How to switch UITableView’s NSFetchedResultsController (or its predicate) programmatically?, TechZen wrote that:
Just make sure to send the tableview itself a beginUpdates before you
swap controllers and then an endUpdates when you are done. This
prevents the table from asking for data in the narrow window when the
FRC are being swapped out. Then call reloadData.
Could you explain exactly what does it mean?
Assuming that the logic to generate the correct fetch (some kind of conditional statement) is in the getter of your NSFetchedResultsController instance. Then it is really easy
Edit: adding complete code sample of something I’ve done. Basically I have a NSDictionary entityDescription that hold values to customize the creation of a NSFetchedResultsController. If I want to change the fetchRequest I change my entityDescription variable to indicate the new values and override the setter to reset the fetchedResultsController and reload the table. It gives you the basic idea.