I have a workflow in my app where the user will build a compound filter and then press a button to view the results of the filter.
In the screen that builds the filter they get to select from a list of fields and set what the value should be. There is also a UILabel that shows how many results match the currently selected filter.
I use an NSFetchedResultsController to make it easier to get the count and change the predicates etc…
When the user presses “Next” (or whatever the button is labelled) they will then view a TableView with those results in it.
Is it bad practise to pass the NSFetchedResultsController in to the tableViewController?
Or should I just pass the information required to build a new NSFetchedResultsController (i.e. the NSPredicate).
I can do either just not sure if there are any pros/cons of either method?
NSFetchedResultsController has a delegate on it. You will have to assign a new delegate when passing the NSFetchedResultsController, and you will have to assign the delegate again when removing the view controller you presented base on the pressing of that button. Keep also in mind that when you are changing the predicate of the NSFetchedResultsController’s fetch request, you are performing another fetch. Basically, you are complicating your architecture while gaining basically nothing. Create a new NSFetchedResultsController object.