Say I have entities organized in a hierarchy with Parent
being the root entity and Child
being a subclass of Parent
. I'd like to setup an NSArrayController
to fetch only entities of Parent
, but not Child
.
If you set the Entity Name of the array controller in Interface Builder to Parent
, it fetches all Parent
and Child
entities. I originally tried setting the array controller's fetch predicate in Interface Builder to:
entity.name == "Parent"
This worked for an XML store, but when I switched to a SQLite store, it no longer worked. I get the following error:
keypath entity.name not found in entity <NSSQLEntity xxx>
As a work around, I am setting up a filter predicate (with the same entity.name
predicate as above) in my awakeFromNib
to filter only Parent entities. Apparently, that predicate is valid once the entities are in memory, but you can't use it in a SQL-backed fetch predicate.
Is there a way to fetch only Parent
entities, but not Child
entities using a fetch predicate that works with a SQLite store? It seems wasteful to pull in entities that you're only going to ignore with the filter predicate.