我在设置一个NSManagedObjectContext
视图控制器时遇到问题 - LibraryTrackTimeViewController
。我附上一个截图(我希望这不违反这里的规则)以使其更清楚:
如您所见 - 它嵌入在 aNavigationController
和 atabBarContoller
中。我正在NSManagedObjectContext
为其他 viewControllers设置appDelegate
:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UINavigationController *navigationController = (UINavigationController *)[[tabBarController viewControllers] objectAtIndex:0];
TagLibraryViewController *tagLibraryViewController = (TagLibraryViewController *)[[navigationController viewControllers] objectAtIndex:0];
tagLibraryViewController.managedObjectContext = self.managedObjectContext;
navigationController = (UINavigationController *)[[tabBarController viewControllers] objectAtIndex:1];
LibrariesViewController *librariesViewController = (LibrariesViewController *)[[navigationController viewControllers] objectAtIndex:0];
librariesViewController.managedObjectContext = self.managedObjectContext;
MapViewController *mapViewController = (MapViewController *)[[tabBarController viewControllers] objectAtIndex:2];
mapViewController.managedObjectContext = self.managedObjectContext;
return YES;
}
其他视图控制器很容易通过managedObjectContext
- 但我无法解决如何将它发送给我的问题,LibraryTrackTimeViewController
因为它是嵌入式的。你可以给我的任何帮助或建议 - 这太棒了!有没有更好的方法将其发送objectContexts
到我的视图控制器?