With refactoring out of the way, now it’s time to put the UI together.
Double-click the RootController.xib file in Xcode to open it in Interface Builder. Then double-click on the View icon in the RootController.xib window to bring up the View window, and drag a table view from the Library window into the view. You’ll find the table view under Cocoa Touch→Data Views in the Library window.
UITableView in the
view, as shown in Figure 5-4. You must confirm
that you’ve dropped it as a subview of the main view by clicking the View
Mode widget on the menu bar of the RootController.xib
window and choosing List View. It should look as shown in Figure 5-4, with Table View
appearing under View. Save the .xib file using
Figure 5-4. Dragging a UITableView from the Library window into the UIView
Switch back to Xcode to add the outlets and delegates Interface
Builder needs so that you can connect the
UITableView to your code. Open the
RootController.h interface file and add a
UITableView variable to the
then declare this as a property and an
IBOutlet. You also need to declare that this
class implements both the
UITableViewDataSource and the
protocols. This means that it both provides the data to populate the table
view and handles events generated by user interaction with the table
Once you’ve done this, the RootController.h ...