wiki:AppleCurrencyConverterAddingCustomClassesToTheNib

Version 5 (modified by mikel, 6 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:

!InterfaceBuilder's Library window

Drag an Object from the Library window and drop it into the main CurrencyConverter? window:

Attachments