I'm trying to filter the child of relationship in coredata but the problem is that Coredata filters by parent and this is correct but it isn't filtering the childs.
Model:
Volumen <-->> MusicScore
I want filter the musicscore rows by volumen.
My NSPredicate is that:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(relation_music_score, $musicscore, ANY $musicscore.nameMusicScore CONTAINS[cd] %@).@count > 0", searchStr];
self.collectionVolumen = [BOIVolumen MR_findAllWithPredicate:predicate];
CoreData get me all volumes that contains the name of music score searched but I want the all volumens with only the music score searched not all music score.
Example:
Volumens
name = "One",
etc..
relation_music_score = NSOrderedSet
Music Score (1)
name = "One"
Music Score (2)
name = "two"
Volumens
name = "Two",
etc..
relation_music_score = NSOrderedSet
Music Score (3)
name = "three"
Music Score (4)
name = "four"
When I'm searching the music score with name "two" I want this result:
Volumens
name = "One",
etc..
relation_music_score = NSOrderedSet
Music Score (2)
name = "two"
And the previos NSPredicate get me:
Volumens
name = "One",
etc..
relation_music_score = NSOrderedSet
Music Score (1)
name = "One"
Music Score (2)
name = "two"
EDIT:
I'm trying the filter the relationship with this predicate and code:
for (int i = 0; i < [self.collectionVolumen count]; i++) {
BOIVolumen *volumen = [self.collectionVolumen objectAtIndex:i];
NSOrderedSet *musicStore = [[self.collectionVolumen objectAtIndex:i] relation_music_score];
NSPredicate *filterMusicScore = [NSPredicate predicateWithFormat:@"nameMusicScore CONTAINS[cd] %@", searchStr];
NSOrderedSet *musicStoreTemporal = [musicStore filteredOrderedSetUsingPredicate:filterMusicScore];
volumen.relation_music_score = musicStoreTemporal;
}
and always I get this error The left hand side for an ALL or ANY operator must be either an NSArray or an NSSet. I was finding and I didn't found nothing.