Unrecognized selector geschickt Instanz

Nicht allzu sicher, wie Sie Sie Debuggen.

2013-01-24 20:36:18.448 SlideMenu[2069:c07] *** Terminating app due to uncaught exception     'NSInvalidArgumentException', reason: '-[initViewController viewControllers]: unrecognized selector sent to instance 0xac6cdb0'

Hier initViewController.m

#import "initViewController.h"
#import "ECSlidingViewController.h"
#import "MenuViewController.h"

@interface initViewController ()

@end

@implementation initViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        //Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Main"];

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    //Dispose of any resources that can be recreated.
}

@end

Ehrlich gesagt, ich bin mir auch nicht sicher, ob die exception geworfen wird, in diesem Stück code. Vielen Dank für jede Hilfe

EDIT:

Gefunden, wo die exception wird geworfen:

    NSMutableArray *lists = [NSMutableArray arrayWithObjects:list1,list2,list3,list4,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;
}

EDIT 2:

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"]];
    ListDoc *list3 = [[ListDoc alloc] initWithTitle:@"Wolf Spider" thumbImage:[UIImage imageNamed:@"wolfSpiderThumb.jpg"]];
    ListDoc *list4 = [[ListDoc alloc] initWithTitle:@"Lady Bug" thumbImage:[UIImage imageNamed:@"ladybugThumb.jpg"]];
    NSMutableArray *lists = [NSMutableArray arrayWithObjects:list1,list2,list3,list4,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;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    //Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    //Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    //Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    //If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    //Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    //Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    //Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
Schau mal in deinen code für etwas, das aufrufen der viewControllers Methode von einem Objekt. Es scheint, dass für die falsch - Objekt.
Fügen Sie eine Ausnahme Haltepunkt, um zu sehen, wo der Anruf auf die nicht vorhandene viewControllers Methode aus. Gehen Sie auf den breakpoint-navigator in Xcode (cmd+6), dann klicken Sie auf "+" unten und wählen Sie "Add Exception Breakpoint...".
assert([navController isKindOfClass:[UINavigationController class]]);
Sorry Sie werden spezifischer sein müssen. Nicht vertraut mit assert()
assert ist ein scheitern, wenn die Bedingung unwahr ist. Im Versuch zu bestätigen PhillipMills Idee, dass Sie nicht wirklich BEFASSEN sich mit einem navController!

InformationsquelleAutor STANGMMX | 2013-01-27

Schreibe einen Kommentar