The ConverterController object needs to communicate with the user interface elements in the Currency Converter window. It must also communicate with an instance of the Converter class, defined in “Defining the Model.” The Converter class implements the conversion computation.
The file ConverterController.h should be open for editing. If it is not, open it in Xcode. Now, you are going to add the outlets required by the ConverterController class. Currently, the ConverterController class is defined as an empty class inheriting from the NSObject class. You will need to add three outlets: one for each of the three text fields in the view. Add the following lines in between the brackets of the ConverterController class:
IBOutlet NSTextField *amountField; |
IBOutlet NSTextField *dollarField; |
IBOutlet NSTextField *rateField; |
Notice that the three text field outlets are of type NSTextField. Because Objective-C is a dynamically typed language, it’s fine to define all the outlets as type id. However, it’s a good idea to get into the habit of setting the types for outlets since statically typed instance variables receive much better compile-time error checking.
Last updated: 2007-10-31