user2053760
user2053760

Reputation: 1703

core data 1 to many selection predicate

I have two entities: class and student. each class can have many students, that is 1 to N reletionship. class entity has two proerties : class name and toStudent; student entity has two properties: student name and toClass;

How do I set the predicate so that I can get an array of classes which do not contain a specific student name. If the class does not have any student, it should also be in the array.

Upvotes: 0

Views: 26

Answers (1)

Adithya
Adithya

Reputation: 4705

Try the below predicate

predicate = [NSPredicate predicateWithFormat:@"(SUBQUERY(toStudent, $student, $student.studentname == %@).@count == 0)",@"student_name_here"];

Upvotes: 1

Related Questions