How to write a master data predicate for filtering for certain types of sub-entities?

I have an entity called FObject with several entities, for example Foo1, Foo2 and Foo3. I have several table views that should display information about different sets of entities, for example, one shows only Foo2s and Foo3s, and the other shows all of them.

How to write a predicate for filtering by entity type, given what I retrieve on FObject?

I tried "entity.name IN% @" and provided a list of entity names, but that didn't work.

Or do I just need to filter the returned results?

Or do I need to add an attribute that encodes a type and use "type IN% @"?

+3
source share
1 answer

If you have different table views to display instances of different sub-arguments, you probably have NSArrayControllers for each table, right? If so, why not set the entity name for the array controller to the desired sub-entity name?

This is the name used in the fetch request (where you specify the name of the object to retrieve). The predicate used in the selection query is used to filter by attribute or relationship, rather than by the name of the object.

0
source

Source: https://habr.com/ru/post/1723554/


All Articles