I'm just learning Core Data. In my app, I have a tableview that displays reviews either alphabetically or by rating, based off a segmented control. So let's say the segmented control is initially on alphabetical, and the results have come back. Next, the user clicks on rating. I already have all the reviews I need within the fetchedresultscontroller; I just have to reorder them. Is there a way to tell the fetchedresultscontroller to reorder its results based off the new sort descriptor (rating) that I give it, or will I just have to do a new fetch?
My concern is that doing a new fetch will be worse performance-wise rather than just reordering the results that have already been fetched. I just wanted to see if this is possible or not.
You should definitely re-fetch.
First, after updating your objects, there will be trips to the store anyway in order to record the rating information. The fetch is a minimal addition to that.
Even if the data is all there already, it would be much worse to either maintain a separate array, or load the controller with more complexity by modifying the datasource methods to reflect the sorting logic. The sorting logic belongs to the fetched results controller.
Remember that the NSFetchedResultsController
optimizes for display in a table view. Expect it to only fetch the absolute minimum that is necessary to display what is visible on screen. You don't have to worry about performance. I have had this kind of setup with 100K+ records without any noticeable performance issue.