I've been beating my head against the keyboard for a better of 3 days now in researching and trying to figure out how i can solve the following problem.
I have a story board that looks like this:
Initial app launch arrow -> to a Navigation Controller -> to the Main View Controller.
My appDelegate is creating the managedObjectContext and it populates some entities with data (for testing purpose only atm, it will be removed once I'm ready to integrate with an outside source). This work fine. Now my problem is that I don't know how i can pass the MOC from the appDelegate to my first ViewController because the Navigation controller is in the way. My current code in the appDidFinish Method looks like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Pass the managed object context to the root view controller
MainMenuViewController *rootView = (MainMenuViewController *)self.window.rootViewController;
rootView.managedObjectContext = self.managedObjectContext;
//My actual Core data setup and adding data to it, it works I've tested it.
return YES;
}
Now my code works when I change where the app launch arrow in the storyboard to point to my mainMenuViewController, but than I do however lose my navigation bar in all my views. I also know how to pass the MOC from my mainMenu to another view via the - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
but I just can't seem to figure out how to do the initial pass from the appDelegate to the MainViewController because of the darn navigation controller being in-between the two.
I've already searched numerous threads on this site (and others) and i've only found the solution for a "Tabbed application" and others want me to serialize the object, but for my purposes I can't do that. (only a few views will receive the MOC and other will be passes data that one view has created and altered to be tailored for specific purposes in the unique views)
Any help to this nub in iOS and Objective-C is greatly appreciated. Thank you in advance.
EDIT: THe error i get is "terminating app due to uncaught exception ... [UINavigationController setManagedObjectContext] unrecognized selector sent to instance...