How to deal with many to many relationships with NSFetchedResultsController?

前端 未结 1 1385
挽巷
挽巷 2021-02-10 11:46

OK so I have two entities in my data model (let\'s say entityA and entityB), both of these entities have a to-many relationship to each other.

I have setup a NSFetchedR

相关标签:
1条回答
  • 2021-02-10 12:49

    You will get that because the call @"entityB.title" is going to return an array|set of titles. That is what you are seeing as it is translating into:

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

    To fix this, you need to reverse your NSFetchedResultsController so that you are fetching EntityA objects through EntityB objects. Then your sectionKeyPath (and your primary sort) would be against just @"title".

    0 讨论(0)
提交回复
热议问题