I'm working on a simple iPhone app.
I have 1 UINavigationController and 2 subclasses of UIViewController.
I have a MainWindow.xib file, a PersonListView.xib, and a PersonDetailView.xib.
The MainWindow.xib has the UINavigationController with the view linked over to the PersonListView.xib file.
The PersonListView.xib has the File's Owner listed as a PersonListViewController class.
I have some buttons on the PersonListView, along with labels and images. All displays correctly.
When I try to link a button on the PersonListView to my PersonListViewController class, the button is not firing....
The result: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UIViewController viewDetail]: unrecognized selector sent to instance 0x450d50'
If I go into the debug console and print-object 0x450d50, I get:
(gdb) print-object 0x450d50 (gdb)
The Interface Builder correctly shows the File's Owner as a PersonListViewController, so why would my button action (linked to the File's Owner) go to the superclass somehow?
EDIT1: Ok, what seems to be happening is that I wasn't getting an instance of the subclass unless, in my MainWindow.xib, I explicitly set the class of the view controller to my subclass.
There's still got to be something I'm missing, though, because surely I should be able to start up arbitrary subclasses of UIViewController just by swapping out the NIB file name from the main window?
EDIT2: (Response to Kevin) That's not what I'm saying regarding the contents of a XIB.
I have 3 XIBs:
MainWindow PeopleListView PeopleDetailView
The PeopleListView and PeopleDetailView each have an associated File's Owner that is a corresponding UIViewController subclass. Obviously, I need my events to go to the right controller classes as I move from page to page...but if I can only use a default UIViewController or one subclass, that will be much more difficult?
I can get the correct effect in code by manually setting up the UINavigationController with the correct root, but I feel like there should be a better way through InterfaceBuilder.
EDIT3: (to Kendall) I'm not using a tab bar. The model is the same, though, that the view in my navigation controller has to be wired to a single subclass, which seems a bit icky.
EDIT4: (to lostintransit) The PersonListViewController has the appropriate - (IBAction) viewDetail; method. The problem is that I can't find a way, in my MainWindow.xib, to flag the view inside my UINavigationController as "initially load this from PersonListView.xib, with a PersonListViewController as the view" that wouldn't make it difficult to replace the PersonListView with a PersonDetailView.