문제

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.

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top