不太确定如何调试它。
2013-01-24 20:36:18.448 SlideMenu [2069:c07] ***由于未捕获的异常'NSInvalidArgumentException'终止了应用程序,原因:'-[[initViewController viewControllers]:无法识别的选择器发送到实例0xac6cdb0'
这是initViewController.m
#import "initViewController.h"
#import "ECSlidingViewController.h"
#import "MenuViewController.h"
@interface initViewController ()
@end
@implementation initViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Main"];
}
@end
在抛出异常的地方:
AppDelegate.m
#import "AppDelegate.h"
#import "MainViewController.h"
#import "ListDoc.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
ListDoc *list1 = [[ListDoc alloc] initWithTitle:@"Potato Bug" thumbImage:[UIImage imageNamed:@"potatoBugThumb.jpg"]];
ListDoc *list2 = [[ListDoc alloc] initWithTitle:@"House Centipede" thumbImage:[UIImage imageNamed:@"centipedeThumb.jpg"]];
NSMutableArray *lists = [NSMutableArray arrayWithObjects:list1,list2,nil];
UINavigationController * navController = (UINavigationController *) self.window.rootViewController;
MainViewController * mainController = [navController.viewControllers objectAtIndex:0];
mainController.someData = lists;
// Override point for customization after application launch.
return YES;
}
@end
最佳答案
从您的帖子:
2013-01-24 20:36:18.448 SlideMenu [2069:c07] *由于以下原因终止了应用
未捕获的异常“NSInvalidArgumentException”,原因:
'-[initViewController viewControllers]:无法识别的选择器发送到
实例0xac6cdb0'
找到引发异常的位置:
UINavigationController * navController = (UINavigationController *) self.window.rootViewController;
MainViewController * mainController = [navController.viewControllers objectAtIndex:0];
这是我的阅读:
项
navController
是initViewController
的一个实例,可能不是您所期望的。initViewController
可能不是UINavigationController的子类。如何调试?尝试这个 :
NSLog(@"%@", [navController class]);