I have two Entities, Student and Course, where each has a to-many relationship to the other (i.e., a Student has 0 or more Courses, and a Course has 0 or more Students).
I need to obtain all Students who are enrolled in a Course. I also need to obtain all Courses in which a given Student is enrolled (by firstName).
An pseudo-predicate would be: all students who have a course whose name is equal to courseName.
So my question consists of two parts:
- What is a valid NSPredicate for obtaining all students with a certain course name?
- What is a valid NSPredicate for obtaining all courses where a student with a certain firstName is enrolled.
For your reference, here are my entities:
NSSet
property in yourNSManagedObject
subclass, which returns students for a course object and courses for a student object. – Akhilrajtr