Define the Classes of Travel Advisor

Travel Advisor has three classes: Country, Converter, and TAController. Only TAController has outlets and actions. And, rather than defining the Converter class, you are simply going to add it to the project from the Currency Converter project and reuse it.

Specify the Country and TAController Classes

Subclass NSObject to create the Country and TAController classes.

  1. In Interface Builder, bring up the Classes display of the nib file window.

  2. Select NSObject as the superclass.

  3. Choose Subclass from the Classes menu.

  4. Type Country in place of MyObject.

  5. Repeat for TAController.

Specify TAController’s Outlets and Actions

Now that the interface has been laid out, you can define the outlets that let TAController communicate with the UI objects. While here, you can also add the outlet for the Converter object that will be reused from the Currency Converter project.

  1. Select TAController and choose Add Outlet from the Classes menu.

  2. Add the following outlets:

    celsiusField
    commentsField
    commentsLabel
    converter
    countryField
    countryTableView
    currencyDollarsField
    currencyLocalField
    currencyNameField
    currencyRateField
    englishSpokenSwitch
    fahrenheitField
    languagesField
    logisticsForm

In addition to outlets, you must specify actions so that the UI objects can message TAController.

  1. Select TAController and choose Add Action from the Classes menu:

  2. Define the following action methods:

    addRecord:
    blankFields:
    convertCurrency:
    convertTemp:
    deleteRecord:
    handleTVClick: ...

Get Learning Cocoa 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.