How to share a ManagedObjectContext when using UITabBarController

前端 未结 9 2341
一整个雨季
一整个雨季 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:30

    Hello I know this is an old thread, but I'm also having problems finding the best way to handle sharing a MOC between TABS - wish Marcus Zarra's link on the subject was still active. Marcus totally rocks, makes data cool.

    This is my current solution in application didFinishLaunching:

    NSArray *viewControllers = [tabBarController viewControllers];
        NSManagedObjectContext *context = self.managedObjectContext;
        for (id viewController in viewControllers) {
            [viewController setManagedObjectContext:context];
    
    }
    

提交回复
热议问题