CREATING THE APPLICATION

In this section, you create the user interface for the application. You'll use a Table View to display the users that you have discovered on the network. As users are discovered, they will be added to the Table View.

TRY IT OUT: Creating the Application's UI

  1. Using Xcode, create a Single View Application (iPhone) project and name it Bonjour. Use this project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Select the BonjourViewController.xib file to edit it in Interface Builder. Populate the View window with the following views (see Figure 18-1):
    • Label (set its text to Discovered Users and Debug statements)
    • Table View
    • Text View

    image

    FIGURE 18-1

  3. In the BonjourViewController.h file, add the following bold statements:
    #import <UIKit/UIKit.h>
    
    @interface BonjourViewController : UIViewController
    <UITableViewDelegate, UITableViewDataSource>
    {
        IBOutlet UITableView *tbView;
        IBOutlet UITextView *debug;
    }
    
    @property (nonatomic, retain) UITableView *tbView;
    @property (nonatomic, retain) UITextView *debug;
    
    -(void) resolveIPAddress:(NSNetService *)service;
    -(void) browseServices;
    
    @end
  4. In the BonjourViewController.xib window, perform the following connections:
    • Control-click the File's Owner item and drag and drop it over the TableView. Select tbView.
    • Control-click the File's Owner item and drag and drop it over the ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.