I had 4 UITableView which represents 4 tabs from my UITabBar. So I have an unique custom TableViewController which controls every screen depending on the entity (on CoreData) it has to display.
In order to fetch elements from CoreData I use a NSFetchedResultsController.
But my problem is, for marketing reasons, I have to merge 2 screens which means displaying 2 entities in the same screen. So I have to fetch elements from 2 different entities. I also have an abstract entity “Element” which is a SuperClass that I use in my TableViewController to control each entity abstractly.
What is the best solution ?
- Do I have to rewrite my Model to merge those 2 entities (this is a problem because the 2 entities are a bit different)
- Can I tell to my NSFetchedResultsController to fetch 2 entities ? How ?
- Can I tell to my NSFetchedResultsController to fetch the Element entity and afterwards to predicate those Entities ? How ?
Thank you in advance !
I finally found a solution that I havn’t proposed.
I have added a new Abstract Entity which is a superclass for the 2 I wanted to merge but which is an “element” child also.
So my ElementListViewController still show “Elements” and I can show the merged Entity for my screen.
I’m now working on migrating old model into new one.
May this post be helpful one day …