How to deal with many, many relationships with NSFetchedResultsController?

OK, so I have two entities in my data model (albeit entity A and entityB), both of these entities have many relationships to each other.

I have NSFetchedResultsController installed to get entityA bunch. Now I'm trying to get the partition names for tableview to be entityB.

sectionNameKeyPath:@"entityB.title"

Now this causes a problem when the title of the section returned from this relationship displays ({title1}) or ({title1, title2 ... titleN}), obviously, depending on how many different people are involved. It does not look great in the table view and does not group objects as we would like.

I would like a section for each title of entities with entity A to appear under each section, if necessary, in several sections. I don’t understand how I should achieve this, do I need to update the predicate to make the object appear several times or do I need to update the section and header functions in order to do some processing as the controller goes through the objects.

Any help is appreciated :)

thank

+5
source share
1 answer

You will get this because calling @ "entityB.title" is going to return an array | set of names. This is what you see, as it translates into:

NSSet *titles = [myEntityA valueForKeyPath@"entityB.title"];

, NSFetchedResultsController, EntityA EntityB. KeyPath ( ) "title".

+5

All Articles