Q: Predicate for child objects iphone I see this in the predicate programming guide:
If you use a to-many relationship, the construction of a predicate is slightly different. If you want to fetch Departments in which at least one of the employees has the first name "Matthew," for instance, you use an ANY operator as shown in the following example:
NSPredicate *predicate = [NSPredicate predicateWithFormat:
    @"ANY employees.firstName like 'Matthew'"];

With the above construction, it would return the department with all employees objects associated to it, provided at least one of the employees have first name as 'Matthew'.
I would like to modify this to fetch ONLY those employees with first name as 'Matthew'.
So if the department has only 2 employees matching this first name, only 2 employee objects should be returned.
How can I achieve this?
thanks.

A: You're executing this agains a set of Department objects, so you can only get back Department objects.  If you want Employee objects instead, you'd have to do something like this:
Department *aDepartment = ...;
NSArray *employees = [aDepartment employees];
NSPredicate *filter = [NSPredicate predicateWithFormat:@"firstName = 'Matthew'"];
NSArray *matthews = [employees filteredArrayUsingPredicate:filter];

Also, since your LIKE filter doesn't have any ? or * symbols in it, it is equivalent to an "isEqual:" comparison.
