1
votes

I'm developing a Core Data Master-Detail application. The detail view is a tabbed interface with each tab displaying different aspects of the model object.

Therefore, I have a:

  • Master view controller (subclass of UITableView).
  • Tab bar controller (default UITabBarController, not subclassed).
  • 3 Detail view controllers contained within the tab bar controller.

When my application segues from the master view controller to the tab view controller, where do I stash the selected model object?

How do I share this model object with all the detail views contained within tab bar controller?

3
Most of my research turned up questions about the opposite, embedding both master and detail inside a tabbed interface or pre-Storybard solutions that do not fit well, conceptually.hashemi

3 Answers

0
votes

You can try creating a shared data object AKA singleton design pattern. Set the selected model object inside a variable in singleton instance and access it from your viewcontrollers inside the tab bar.

0
votes

Each view should only concern itself with the data (part of the model) that it needs to manage. Therefore each of the view controllers (1 master and 3 details) should have properties to store the data (again, the part of the model) that it uses. For example, for the master, it is most likely to have a list of the objects, each or a combination of them, but for each of the detail views, only pertinent data need to be kept by the view controller.

Hope this helps. I would be interested to learn your solution to this problem.

0
votes

I'm in much the same situation. However, I have subclassed my UITabBarController so my plan is to have the UITabBarController hold the model object and pass it into each of the detailViews if/when the model changes.