Say I have entities organized in a hierarchy with Parent being the root entity, and Child is a subclass of Parent . I would like to configure NSArrayController to retrieve only Parent objects, but not Child .
If you set the Entity Name of the array controller in Interface Builder to Parent , it will select all the Parent and Child objects. I originally tried to set the fetch predicate for an array controller in Interface Builder for:
entity.name == "Parent"
This worked for the XML repository, but when I switched to the SQLite store, it no longer worked. I get the following error:
keypath entity.name not found in entity <NSSQLEntity xxx>
As a job, I set up a filter predicate (with the same entity.name predicate as above) in my awakeFromNib to filter only parent objects. Apparently, this predicate is valid after objects are in memory, but you cannot use it in SQL-backed fetch predicate.
Is there a way to get only Parent objects, but not Child entities using a select predicate that works with SQLite repository? It seems wasteful to pull objects that you just ignore with the filter predicate.
source share