Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Storyboard / iPad / error "unrecognized selector sent to instance"

Tags:

ios

I am new to this site and to iOS programming; so, please forgive me if I am missing anything to ask a proper question, but I have read the params and some answers already--no answer yet to my small issue.

All I am trying to do is a creating a File/New/Master Detail Application/Storyboard box checked/ ARC box checked / DeviceFamily: iPad...

Then my Storyboard shows :

initial segue*==>*SplitViewController screen-->NavigationCotroller screen-->TableView screen

the SplitViewController is also connected to NavigationCotroller screen and DetailViewController

The problem is when I pick a single ViewController from the Objects drag it to the canvas, put it on the left side of the existing SplitViewController screen THEN move the initial segue to this new ViewController. Without making any other change I run it and it crash with the below error message.

I am getting this error:

2012-02-23 11:09:50.526 Lab4[1815:f803] -[UIViewController topViewController]: unrecognized selector sent to instance 0x6c69b90 2012-02-23 11:09:50.528 Lab4[1815:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController topViewController]: unrecognized selector sent to instance 0x6c69b90' * First throw call stack: (0x13bd052 0x154ed0a 0x13beced 0x1323f00 0x1323ce2 0x1f57 0x129d6 0x138a6 0x22743 0x231f8 0x16aa9 0x12a7fa9 0x13911c5 0x12f6022 0x12f490a 0x12f3db4 0x12f3ccb 0x132a7 0x14a9b 0x1e18 0x1d75 0x1) terminate called throwing an exception <

Then I move the initial segue back to the SplitViewController run it and no crash.... ???

Can anyone guide me on this one?

Thanks, Rick.

like image 602
Zeraus Avatar asked Dec 06 '25 02:12

Zeraus


1 Answers

In the AppDelegate there is code that sets the splitViewController from the rootViewController:

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
return YES;

The application is expecting a UISplitViewController so things go wrong when you set the initial view as a generic UIViewController.

If you want to use this single view on the left side keep the UISplitViewController as the initial view and ctrl-drag from the UISplitViewController to the new view and click Relationship - masterViewController

like image 165
Rupert Horlick Avatar answered Dec 07 '25 18:12

Rupert Horlick