I have a superentity called FObject w开发者_Go百科ith several subentities, say Foo1, Foo2, and Foo3. I have a number of tableviews that should show information about different collections of the subentities, so for example, one shows only Foo2s and Foo3s while another shows all of them.
How do I write a predicate to filter on the subentity type, given that I am fetching on FObject?
I tried "entity.name IN %@" and provided a list of entity names but that did not work.
Or should I just filter the returned results?
Or should I add an attribute that codes the type and use "type IN %@"?
If you have different table views to show instances of the various sub-entities, you presumably have NSArrayControllers for each table, correct? If that's the case, why not set the entity name for the array controller to the desired sub-entity's name?
This is the name used in the fetch request (where you specify the entity name to fetch). The predicate used in the fetch request is used to filter by attribute or relationship, not entity name.
精彩评论