I’m trying to build an iPad app working with Core Data.
But I’m facing a design and a coding issue.
Let’s say I add one UIViewController to my window and inside that viewcontroller, I need to display two tableviews (2 different entities) and 2 views (2 others entities) (So I need to fetch 4 entites for one UIViewController).
I only found tutorials explaining how to use NSFetchedResultsController with one UITableView !
My question is : Should I declare 2 UITableView and 2 NSFetchedResultsController in my viewController ? Or should I declare 2 UITableViewController and then inside each of them declare one NSFetchedResultsController ?
What about the two others views ? I should use NSFetchRequest ? If yes, where ? inside the views or inside the UIViewController ?
I know it’s a lot a questions :).
Thanks in advance for your help.
Yes, you’ll want to use 2 NSFetchedResultsController, one per UITableView. NSFetchedResultsController takes a NSFetchRequest, so you’ll want to setup your NSFetchRequests based on the data that needs to be displayed in the UITableViews.
You should put all this controller logic inside your UIViewController subclass.
It is fine to have multiple UITableViews inside a single UIViewController, just keep in mind the delegate and data source methods. You’ll have to test the UITableView parameter to see which table is asking for data/delegation handling.