Question

I am working on an iOS application where I am trying to fetch results that are based on the Entity's relationship entity. This relationship entity has yet another relationship entity, and it is this second entity's attribute that I would like to use in my predicate. The predicate that I am trying to form is:

NSString *filter = @"name";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"EntityB.EntityC.attributeOfEntityC == %@", filter];

Is this construction of a predicate correct? If not, how would I go about constructing one such that it fulfils the criteria that I require?

Was it helpful?

Solution

The predicate should name the actual relationships involved, not the names of the entities.

ie:

[NSPredicate predicateWithFormat:@"relationshipNameToEntityB.relationshipNameToEntityC.attributeNameOnEntityC == %@", filter];

This is all going to be very vague without more details about your entities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top