1

不太清楚如何调试。

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
4

1 回答 1

3

从你的帖子:

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]);

于 2013-01-27T21:11:25.423 回答