Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS / Core Data - How can I change sectionNameKeyPath of a NSFetchedResultsController?

I declared my fetchedResultsController like this

NSFetchedResultsController *fetchController = [[NSFetchedResultsController alloc] 
initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext 
sectionNameKeyPath:@"date" cacheName:nil]; 

But when I click on a UISegmentedControl, I want to change the sectionNameKeyPath to be @"title".

Do you know a way to do so ?

Thanks

like image 749
Dabrut Avatar asked May 04 '12 09:05

Dabrut


1 Answers

You would need to redefine the FRC and reinitiate the fetch request. Either set a property on the class to hold the value of the current sectionNameKeyPath (set the default in the viewDidLoad event), or you can pass that in to the method that instantiates and executes the FRC.

like image 135
LJ Wilson Avatar answered Oct 04 '22 12:10

LJ Wilson