There are two different problems:
To get from
Fruit
to the relatedSource
you have to use the relationship:@"fruitSource.sourceName contains ..."
instead of@"Source.sourceName contains ..."
.(This is probably causing the exception.) The
%@
format requires an Objective-C object as argument, not a C string:@"Apple Tree"
instead of"Apple Tree"
.
So the predicate should look like this:
[NSPredicate predicateWithFormat:@"fruitSource.sourceName CONTAINS[cd] %@", @"Apple Tree"]