Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data parent Entity

I have an abstract Entity A, I also have two Entities whom's parent is Entity A. Each child has different relationships to other Entities.

I am trying to fetch all child Entities of Entity A, who's isPublic boolean value is YES.

I've had trouble with fetching subclassed Entities in the past in relation to fetching, and I'm sure I'm just not doing it correctly.

So we could say for example that : • Entity A is "Document", • Entity B is "Poem", • Entity C is "Article"

All poems and articles subclass document, and document has a property called isBookmarked, the suer can bookmark a poem or article, and I need a way of fetching all documents that are bookmarked. Entities B and C need to be independent because of other relationships that they own.

I want to use NSFetchedResultsController for optimal Core Data and UITableView performance, and I'm struggling to fetch a mix of poems and articles.

What fetch request would give me a mix of poems and articles ?

enter image description here

like image 567
Daniel Avatar asked Jan 18 '23 02:01

Daniel


1 Answers

The answer of Wienke should work, if you just add

[request setIncludesSubentities:YES];

otherwise you will only receive results of the A entity, which should be non as you said it is abstract.

like image 139
tonklon Avatar answered Jan 30 '23 23:01

tonklon