NSFetchedResultsController result filtering
Is there an easy way to filter the results provided by the NSFetchedResultsController
?
I am using the standard Core Data Template which works very well for simple tables.
What I have is a UITableVIew
with a UISegmentedControl
with two categories, one that displays all and one that when selected should display only events what were created today.
I have been able to accomplish this in two different tableViews (so i know how to use NSPredicate, that is not my problem; the problem is combining it into a single tableView).
I know 开发者_C百科you cannot change the fetchRequest once the NSFetchedResultsController
has been created.
So I can guess that I will have to create a new NSFetchedResultsController
.
Has anyone implemented something like this or have any ideas on how to accomplish this?
Yes, you must create a new NSFetchedResultsController
– after all, changing the fetch request would basically amount to reinitializing it from scratch anyways (due to the operations that NSFetchedResultsController
performs behind-the-scenes on the fetched data).
I haven't used NSFetchedResultsController much as my codebase predates it, however in the past i have just fired off an NSFetechedResults request with a different predicate depending on the state of the segmentedControl.
精彩评论