views:

20

answers:

0

I am trying to figure out how to set up a new NSFetchedResultsController. Here are the steps I am taking:

  1. NSFetchedResultsController retrieves grandparent objects, which I will call "Sets"

  2. Show them up in a UITableView.

  3. Select cell. Pass selected "Set" NSManagedObject to new view controller.

  4. THIS IS WHERE I NEED HELP. I want the view controller create a new FetchedResultsController using the "Set" as a filter based on the unique ObjectID. The FRC should retrieve grandchildren objects ("Items") to use as individual cells and the middle child objects ("Sections") to use as the section headers. Both the "Items" and "Sections" have a "sort" attribute and must be sorted based on that integer.

The problem I run into is that if I just pass the "Set" and traverse the relationship, the Sections and Items aren't sorted correctly. I thought about using an NSPredicate on a new NSFetchedResultsController, but can't figure out how to limit the "Section" and "Item" results to only those related to "Set" based on the unique objectID. I can't rely on the name of "Set" being unique.

Any assistance is appreciated.

UPDATE I still haven't found a way to reference an object by ObjectID in a Predicate with a FetchedResultsController. The only way I have found to do this is to add a property to house a unique key to the object. The problem is that I then have to maintain that key and make sure it is unique. I would really rather use something built into Core Data.