How to share a ManagedObjectContext when using UITabBarController

前端 未结 9 2357
一整个雨季
一整个雨季 2020-12-23 10:57

I have an iPhone application that has a MainWindow.xib holding a UITabBarController, which in turn has a UINavigationController and a custom UIViewController subclass in its

9条回答
  •  清酒与你
    2020-12-23 11:36

    If you want to use the dependency injection method to pass the managed object context with a tab bar controller, a more robust solution would be to loop on all the view controllers in applicationDidFinishLaunching:

    for (id vc in tabBarController.viewControllers) {
        [vc setManagedObjectContext:self.managedObjectContext];
    }
    

提交回复
热议问题