Changes

Jump to: navigation, search
Creating the Second View Controller
== Creating the Second View Controller ==
To create the view controller for the table view that will display the list of books written by the selected author, right click on ''Classes'' under ''Groups & Files'' in the main Xcode project window and select ''Add -> New File''. On the template selection screen, select iPhone OS Cocoa Touch Class followed by the UIViewController subclass icon. Make sure that the ''UITableViewController '' subclass option is selected. We will manually create the NIB file later so leave the ''With XIB for user interface'' option unchecked:
[[Image:Adding_second_tableviewcontroller.jpg|Adding a second view controller to the project]]
 Click on ''Next '' and name the class ''BooksViewController''. Since we will need an interface header file, leave the ''Also create “BooksViewController.h”'' option selected and click ''Finish'' to create the files.
Before we begin work on our second table view we need to make sure that the new class is declared within our root view controller class. To do so, edit the ''RootViewController.h'' file and add code to forward reference the ''BooksViewController'' class and add an outlet to the new view controller:
</pre>
Before we move on to the next step, be sure to save the above changes to the ''RootViewContoller.h '' file by selecting ''File -> Save '' so that the outlet is visible to us from inside Interface Builder. Failure to save the file at this point may result in the outlet not appearing when we try to create connections from within Interface Builder.
== Connecting the Second View Controller to the Root View Controller ==

Navigation menu