I am working on an application which uses a UITabBarViewController to hold two UITableViewControllers.
In the Story Board, I pull out the two UITableVIewControllers which are called firstTVC & secondTVC and then embed them in a UITabBarController.
I have a UIDocument @property with a fetchedResultsController in firstTVC that works great, but I haven’t figured out how to pass the ManagedObjectContext @property from firstTVC to secondTVC.
I have thought about doing it in the app delegate, but I have read that it is considered taboo (especially in iOS 5).
Thanks for reading!
Caborca,
Apple’s standard Core Data template maintains the MOC on the AppDelegate. Why do you have a problem using it? (Yes, some folks believe all singletons are “code smell.”) That said, this is hanging off of a singleton defined by the Cocoa Touch framework. It already exists and is available everywhere in your code.
If that doesn’t work for you and you are instantiating via nibs, then you are going to need to create a custom delegate or read the singleton and store it locally in your -viewDidLoad method.
Andrew