SectionNameKeyPath through multiple relationships

I am working on an application that uses Core Data and NSFetchedResultsController. The model setup is as follows:

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

So, a Parthas an all-to-all relationship with Kit(a part may be in one or more sets, and a set may contain one or more parts). And each Kitcomes from Source, which one or more Kits can provide .

I am currently creating UITableViewone that uses NSFetchedResultsControllerwith a simple listing of all objects Part. I would like to group the parts into sections, with each section having a name Source. I.e:.

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

a Part Source s, NSFetchedResultsController sectionNameKeyPath, -?

!

+5
2

, NSFetchedResultsController , Kit Part by, -.

Objective-C, node , . node . , , , "" ( ).

, Part Kit s? many-many Kit Part , a Kit Part s, Part , sectionNameKeyPath NSFetchedResultsController @"kit.source.name" , .

, , , - Kit Part, , , , NSFetchedResultsController, Source UITableViewDataSource : (

0

, NSFetchedResultsController Many to Many

. : NSFetchedResultsController?

: https://github.com/dmathewwws/Many-to-Many-CoreData

0

All Articles