Efficient implementation of CoreData FetchedResultsController

Hi All


I have a question on the most efficient implementation of coredata NSFetchedRestultsController. Basically, I have 2 UITableViewControllers. UITableViewController No 1 shows a list of Parent entities and UITableViewController No 2 shows list of child entities for each parent. (Parent has one-to-Many relationship to child).

There is an Add button on the navigation bar to Add a new Parent or a New Child (to a particular parent) on each UITableviewController respectively.

The way I have implemented it currently is that both UITableViewControllers have FetchedResultsController methods implemented. So the Parent UITableviewcontroller has a FetchedResultsController to get a list of all parents and also the controller helps to add/remove New Parent entities along with the smooth animations which are default to master-detail style implementation.

For the child UITableviewcontroller, there is an analogus FetchedResultsController with a predicate to fetch the children of a particular parent. Rest everything works exactly the same as the parent. I just pass on the managedObjectContext from the parent to the child but then perform a new fetch request with a predicate on the passed managedobjectcontext.

My question is....is this the most efficient way of doing this? I.e. performing a fetchrequest through the NSFetchedResultsController everytime I goto a child UITableViewController from the parent UITableViewController? It feels like I should be able to jus the NSSet that the Parent managedobject provides and use that to populate the Child UITableViewController rather than perform a new fetch with a predicate. But I am not sure if this would work well with adding/deleting new children to the UITableViewController and, also, is it really that significantly effient from a system resources point of view?

Any help would be appreciated. If you would like me to further clarify, please let me know.

Put 50 or more children on a parent and then consider how the result display works. NSSet is only going to be "better" for relatively trivial numbers of children. At that level of trivialness, you'd get the same sort of benefit from getting your cache and prefetch settings right.


And, like you already noticed, using the NSSet cuts you off from the update mechanisms.

Efficient implementation of CoreData FetchedResultsController
 
 
Q