Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data Fetch Request Relationship Attribute Predicate

I have Father Entity. Father has a one-to-many relationship with Child. Child has attributes and one of them is name.

I want to perform a fetch request to get: Father.name = "Joe" and out of the fathers named joe I want to fetch those that have a child named Ken: Child.name = "Ken"

So my main objective is to find Ken whose father's name is Joe.

I tried some compound predicates and other things but not luck yet.

Any idea how I can solve this?

thank you

like image 582
zumzum Avatar asked Jun 19 '26 01:06

zumzum


1 Answers

Assuming you want the child:

[NSPredicate predicateWithFormat:@"father.name = %@ AND name = %@", @"Joe", @"Ken"]

should work

like image 54
Sherman Lo Avatar answered Jun 20 '26 17:06

Sherman Lo