I am trying to filter a mutable array of objects using NSPredicate and am having trouble access the level that contains the property I would like to filter on.
To give a simplified example consisting of the similar custom objects.
- Grandparent
- Parent
- Child
I have an NSMutableArray of Grandparents and I would like to find all the Grandparent Objects that have GrandChildren of age 10. Therefore the grandchildren are two levels deep from the root. Child has an age property amongst other things.
ie. Grandparents has an array property Parents and Parents has an array property Children and Children has an integer property age.
The following NSPredicate has returned no results. "SELF.parents.children.age == 10"
.
I realise that as these are nested collections this predicate is likely the wrong way to go about it but I am stuck as to how to access that level. Perhaps via a Subquery or Collection Operator but I cannot work it out.
One thing to keep in mind is that I obviously still want GrandParents that have multiple Grandchildren of different ages, one of which is aged 10.