I'm trying to build an NSPredicate to satisfy a given relationship. My data model has the following: University -> College -> Classrooms - ClassroomType
That property is called typeDescription
I want to build a query that can give me all universities that have a typeDescription equal to the value "computerlab". The objects that I have available to me are a list of Universities. I'm pretty sure that I'll need to construct an NSPredicate
SUBQUERY
but I'm not quite sure no how to build this to satisfy my requirements. If anyone has any input on the right way to build this query it would be much appreciated.
For one-to-many-to-many relationships, you need to nest two SUBQUERY clauses:
NSPredicate(format:"SUBQUERY(colleges, $c, SUBQUERY($c.classrooms, $room, $room.classroomType.typeDescription == %@).@count > 0).@count > 0","computer lab")