Navigating the Core Data Object Graph [2]

前端 未结 2 895
遥遥无期
遥遥无期 2021-01-24 07:11

I asked a question yesterday where I really should have started with a simpler example. Having distilled my question to the basics, I\'ve managed to solve my problem using exis

2条回答
  •  轮回少年
    2021-01-24 07:32

    If you've followed the Core Data Guidelines and have set up reciprocal relationships you could try searching from the bottom up.

    Fetch the Entity C objects that pass your required predicate and then get the Entity A object by going up the parents. No need for nested subqueries.

    Edited to add

    You can get the parent of C (which is an object of B) from the parent relationship. And from there you can get the parent (which is an object of A) form the parent relationship.

    It's in your Core Data Model Diagram.

提交回复
热议问题