我正在使用带有初始介绍视图控制器的情节提要,我想将其与具有核心数据的表视图控制器相结合。我知道初始控制器是根控制器,但由于连接到核心数据,我需要第二个控制器作为根控制器。当我在我的应用程序委托中执行以下操作时,我收到此错误:
-[IntroViewController setViewControllers:]:无法识别的选择器发送到实例 0x7465b70 2013-01-21 22:29:15.331 PManager [35522:c07] *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[IntroViewController setViewControllers:]:无法识别的选择器发送到实例 0x7465b70”
我的第一个视图在情节提要中称为“introController”。
我的第二个视图是与情节提要中称为“listController”的核心数据挂钩的表视图。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)options
{
// Get a reference to the navigation controller first
UINavigationController *navigationController = (UINavigationController *) self.window.rootViewController;
IntroViewController *introController = [navigationController.storyboard instantiateViewControllerWithIdentifier:@"introController"];
RootViewController *listController = [navigationController.storyboard instantiateViewControllerWithIdentifier:@"listController"];
// First item in array is bottom of stack, last item is top.
navigationController.viewControllers = [NSArray arrayWithObjects:listController, introController, nil];
// THEN get the root view controller (RootViewController)
RootViewController *rootViewController = (RootViewController *)[[navigationController viewControllers] objectAtIndex:0];
// And now pass the context
rootViewController.managedObjectContext = managedObjectContext;
[self.window makeKeyAndVisible];
return YES;
}