Core Data - NSPredicate to filter to-many relationship

Posted by Macatomy on Stack Overflow See other posts from Stack Overflow or by Macatomy
Published on 2010-03-26T03:59:25Z Indexed on 2010/03/26 4:03 UTC
Read the original article Hit count: 407

I have 2 entities, Task and List. Each task has a to-one relationship to a List object called "list", and there is an inverse relationship with List, which has a to-many relationship with Task called "tasks".

I'm trying to use a fetch request with an NSPredicate to get all the Task objects that belong to a specified List:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"list=%@", theList];
[fetchRequest setPredicate:predicate];

(where "theParent" is a reference to a List object). However this returns no fetched objects. If I take out the predicate, then the objects are returned (so I do know they exist, and by NSLogging theList I know it has Task objects associated with it).

Thanks

© Stack Overflow or respective owner

Related posts about core-data

Related posts about iphone