|Version 9 (modified by mikel, 7 years ago) (diff)|
Adding Custom Classes to the nibfile
Once the user interface for your application looks right, there is still one important task to complete before you can use it. You must record some information in the nibfile about the classes of the objects, so that the application can create them with the right connections in place.
When you use XCode to write an Objective C application, InterfaceBuilder can read the Objective-C header files and use the information in them to create descriptions of the classes in the Objective-C code. When the application is written in Lisp, InterfaceBuilder can't read the class descriptions from the code, and so we'll have to manually tell the nibfile about any classes that we use in the user interface.
As you will see in the following sections, we'll use Lisp code to define two Objective-C classes: Converter, and ConverterController. The Converter class implements the method that performs the actual currency conversion for our application; the ConverterController? class provides communication between the user interface and the Converter object. We need a way to create instances of these two classes in the nibfile, so that launching the application creates these instances, and the connections between them and the rest of the user interface.
Create Instances of Custom Classes
In InterfaceBuilder's Library window, select the Cocoa Objects and Controllers view:
Drag an Object from the Library window and drop it into the CurrencyConverter project window:
Now tell InterfaceBuilder the name of the new object's class. With the Object icon selected in the CurrencyConverter project window, choose the Identity tab of the Inspector. At the top of the Identity view is a "Class" field; type the name of your custom class (in this case, "Converter") into the "Class" field and save the nibfile: