I have a child view controller that requires the managedObjectContext
be set on it in order to operate properly, and while I considered using a singleton this question seems to point strongly to that it should be passed around, starting with the AppDelegate.
I don't know how to pass it to a child view controller, however (note that it's set up via Storyboards). I tried a few ways:
- In
prepareForSegue
, before the embed segue is called, I save a reference to the destination view controller in the containing view controller as a property, then try to access this property, but indidFinishLaunching
the segue obviously hasn't been set up yet. - Accessing the
childViewControllers
property of the containing view controller, but again, atdidFinishLaunching
this is not populated.
So despite the Core Data template and examples seeming to indicate that the managedObjectContext
of other view controllers should be set in didFinishLaunching
, I see no way to.
How would I properly pass the managedObjectContext
onto the view controllers that need it?