For a small app, I have a login screen. On Auth, A tab bar controller with two views (one with navigation controller) is presented. I am following this tutorial. It uses core data. http://maybelost.com/2011/12/tutorial-storyboard-app-with-core-data/
The tutorial calls a segue. But I would like to use presentModalViewController. It works, except I am wondering how to pass a managedObjectContext to the View inside Navigation Control inside tab bar controller.
I read this Passing ManagedObjectContext to view controllers using storyboards with a root UITabBarController, but the comments under second answer say it is not the right method.
Can someone tell me the correct way to do it? I am looking to know how to get a reference to a view inside the tabbar controller so that I can set the managedobjectcontext for that view.
Thanks
EDIT In appDelegate.h:
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
My appDelegate.m :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
LoginViewController *rootView = (LoginViewController *)self.window.rootViewController;
rootView.managedObjectContext = self.managedObjectContext;
}