views:

24

answers:

1

I have an app which is based on the Utility template (where you flip over the view to see another). On the first view there is a login screen, then it flips over to reveal a UITabBar style interface.

I'm having trouble working out how to pass the managedObjectContext from the App Delegate (where it is created) all the way through to each of the Tab Bar's views.

App Delegate's managedObjectContext get passed to FrontLoginViewController which gets passed to BackViewTabBarViewController .. where next?

The BackViewTabBarViewController nib has a UITabBarController with a UINavigationController for each tab.

+1  A: 

Sounds like the managedObjectContext is defined in your AppDelegate. If so, then...

From whatever viewController you want... just call

MyApplicationDelegate *appDelegate = (MyApplicationDelegate *)[[UIApplication sharedApplication] delegate];

Then use...

appDelegate.managedObjectContext

whenever you need the managedObjectContext. Change the MyApplicationDelegate to your AppDelegate and you should be good to go.

Jordan