Question

I'm trying to find out the best way to pass my managedobjectcontext while using view controller containment.

In my delegate all that is instantiated during didFinishLaunchingWithOptions is the rootviewcontroller (SWRevealViewController), but none of its children. My menuController, which is the reveal controller's rear view controller, is loading a dynamic list of menu items using core data objects. Ultimately, I need to pass my MOC to that class.

I'm not sure what other info you guys would need. For those working with this third party code it should be pretty clear, but I can't find any resources on it dealing with MOC and core data.

Thanks in advance.

Was it helpful?

Solution

Give the SWRevealViewController a managed object context as an attribute and pass that on when you initiate other controllers.

Alternatively, you could give your app delegate (where you presumably set up the core data stack) the context and use a convenient macro.

#define MOC [(AppDelegate*)[[UIApplication sharedApplication] delegate] managedObjectContext]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top