I have this Model situation -
Group
entity is in One on One relationship with Event
entity called latestEvent
.Event
entity has a child entity called 'WeddingEvent' which is one of many child events.WeddingEvent
is the only one who has a property called present
Group
to not be fetched if the latestEvent
is of kind 'WeddingEvent'.Since I can not fetch by className or by entityName I tried :
NSPredicate *LatestEventValidity = [NSPredicate predicateWithFormat:@"latestEvent.present != nil"];
AND
NSPredicate *LatestEventValidity = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary * bindings) {
OOVGroup *group = evaluatedObject;
return [group.latestEvent respondsToSelector:@selector(setPresent:)];
}];
But they al failed.
Any help here ?
The first predicate does not work because not all Event objects respond to the "present" selector. The second predicate does not work because you cannot use block-based (or any Objective-C based) predicates in a Core Data fetch request.
The only solution is probably to add a (string or integer) "type" attribute to your "Event" entity, so that you can filter with a predicate like "lastEvent.type != 'Wedding'"
.