I have searched for this but the answer is too simple to satisfy me :(
I want to pass a NSManagedObjectContext
from TabBarController
to almost every view controllers in my app. In detail, my storyboard structure is kind of like this:
TabBarController
>>> several tab items views ( this is easy to pass, just pass one time in according view controllers). But I have another relation: TabBarController
(the one mentioned above) >>> NavigationController
>>> TableViewControllerOne
>>> TableViewControllerTwo
,
now it's disaster. Because basically I have to transfer the NSManagedObjectContext
instance from the NavigationController
to TableViewControllerOne
and to TableViewControllerTwo
....that could involve a lot of prepareSegue:sender
and it's not easy to manage.
So my question is: in iOS development, is there a way that I can create a "global" object that I can easily access in my entire app? From apple's official template for master-detail view using core data, it instantiates the NSManagedObjectContext
in app delegate, passing it to master view controller. What if I have to use this object after several view pass? Wow, that's a lot of code to do.
Hope I made myself clear and someone could help :) Thanks a lot.