I'm using CoreData and NSFetchedResultsController in my project. I have 2 entities School & Students, one to many relationship.. a school can have multiple students.
I'm trying to filter schools by school name and then filter students by grade in such a way that i get a Filtered School that contains ONLY the students that matches certain grade.
let fetchRequest = NSFetchRequest<School>(entityName: "School")
let predicate = NSPredicate(format: "name = %@ AND ANY students.grade","School 2", "F")
The issue with the above mentioned predicate code is that it returns me a "School 2" with ALL the students whereas only one student has "F" grade.
I need a School entity that should contain ONLY the student with "F" grade.