I’ve an iOS project where I’m trying to use CoreData.
In my model, I’ve two class ChildA and ChildB who inherit from ParentClass.
In my UITableViewController, I can easily get all objects with:
NSEntityDescription *entity = [NSEntityDescription entityForName:@"ParentClass" inManagedObjectContext:self.managedObjectContext];
What I’m trying to achieve now is to group results by Classname. But I’ve no idea how to achieve that in my NSFetchedResultsController for the param sectionNameKeyPath
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:@"?????" cacheName:@"Master"];
The result I want to use in my UITableView should look something like
ChildA
Obj1
Obj2
Obj3
...
ChildB
Obj4
Obj5
Obj6
...
Thanks in advance
I’ve found a possible way to achieve that…
I declared two
NSFetchedResultsControllerin myUITableViewControllerThe first one is responsible to manage objects of class
ChildAand the second one is responsible to manage objects of classChildB.Then I managed to use
childAFetchedResultsControllerorchildBFetchedResultsControllerdepends on the current section.Hope it’ll help someone else 😉