Is there a way for the sort descriptor to be dynamically set for the selected result controller on iOS?
For example, I want the results of the master data returned to me to be sorted depending on the setting of the segmented control in the navigation title bar. A user can click a segmented control to sort by price or priority.
Then I need a controller of the results to return and display information about the kernel data, sorted into sections based on this segmented control value.
I know how to set sort descriptors first, but I don't know how to change / update it dynamically. Since the function - (NSFetchedResultsController *)fetchedResultsController lazy loaded, usually it always returns only frc, which was created the first time (thus returning the initial setting of the sort descriptor)?
Will I do something like storing the segmented value of the control in sharedPreferences, and then when it changes, set my fetchedResultsController to nil so that a new one is generated? Then, in the fetchedResultsController function, can I create my sortDescriptor based on this sharedPreferences parameter?
source share