When I create a predicate like this, from outside a subclass of NSManagedObject, it works just fine:
CNSTag *aTag = ...
_predicateForMatchingObjects = [NSPredicate predicateWithFormat:@"ANY tags == %@", aTag];
However, when I try to provide a function for my class CNSTag, as below, the program crashes while trying to create the predicate:
- (NSPredicate *)predicateForMatchingObjects {
_predicateForMatchingObjects = [NSPredicate predicateWithFormat:@"ANY tags == %@", self];
return _predicateForMatchingObjects;
}
If I access key paths of self in the predicate (e.g., "ANY tags.name == %@", self.name), it works fine; I just can't access self. Does anyone know why this is the case?