views:

51

answers:

0

Hello all,

I am working on an app that uses Core Data and an NSFetchedResultsController. The model setup is like this:

/-----------\          /-----------\          /-----------\
|Part       |          |Kit        |          |Source     |
|-----------|          |-----------|          |-----------|
|name       |          |name       |          |name       |
|dimensions |          |description|          |location   |
|...        |          |...        |          |...        |
|-----------|          |-----------|          |-----------|
|kits       | <<-\     |source     | <<-----1 |kits       |
|           |     \->> |parts      |          |           |
\-----------/          \-----------/          \-----------/

So, a Part has a many-to-any relationship with a Kit (a part can be in one or more kits, and a kit can contain one or more parts). And each Kit comes from a Source which may provide one or more Kits.

I am currently creating a UITableView that uses an NSFetchedResultsController with a simple listing of all of the Part objects. I would like to group the parts into sections, with each section being a Source's name. I.e.:

|-------------------------------|
|Source One                     |
|-------------------------------|
|Part One                       |
|Part Two                       |
|Part Three                     |
|-------------------------------|
|Source Two                     |
|-------------------------------|
|Part Four                      |
|Part Two                       |
|Part Five                      |
|....                           |
|-------------------------------|
|             O                 |
|-------------------------------|

Since a Part may come from multiple Sources, is it possible to do this with an NSFetchedResultsController by using the sectionNameKeyPath, or do I have to do this a completely different way?

Thanks!