I have two core data entities "Books" and "BookLists" where "Books" objects have a to-many relationship with "BookLists" objects and am trying to fetch all existing objects of type Books which do not have a relationship to a given object of type BooksList.
I'm fetching all Books objects which DO have a relationship to that BookLists object with the predicate
NSPredicate(format: "booklists CONTAINS %@)", list)
so what I'm looking for is basically a negative version of this predicate but I can't find anything on "negative contains" predicates anywhere.
After Martin R linked me to a similar question, I was able to find the solution for my problem by using a subquery:
NSPredicate(format: "SUBQUERY(booklists, $a, $a CONTAINS %@).@count == 0", list)