The companion files package for this document contains a project that implements the Converter application. Because this tutorial is not designed to teach you Cocoa programming, it doesn’t provide an explanation of what the code does. You’ll find a link to the companion files package in the table of contents of the HTML version of this document.
To see how the application works:
Download and uncompress the companion files package.
Open the project file Converter.xcodeproj.
Click the Build and Go button in the project window’s toolbar.
Verify that the application works correctly.
Interface Builder not only helps you design your user interface, it makes it possible to connect the properties of the various objects in your design. The necessary connections for the Converter application already exist in the nib file found in the companion files package.
In the Converter project window, select the Resources group and open the nib file MainMenu.xib.
Select the Converter Controller object in the MainMenu.xib window, and display the connections inspector.
There are four connections: two outlets for the text fields, a received action for the Convert button, and an application delegate outlet. Figure 3-10 shows the connections in the inspector.
Now select the Convert button in the main window. The connections inspector shows a sent action for the Converter Controller object. This action represents the other end of the received action shown in Figure 3-10. The two text fields and the File’s Owner object have similar complementary connections.
To learn how to make connections, and much more about Cocoa programming, your next step is to read Cocoa Application Tutorial.
To make Converter a solid Mac OS X application, clearly there’s more work to be done. If you’re interested in Cocoa programming, here are a few ideas to improve and extend this application:
Edit the main menu bar using Interface Builder. The default Cocoa application menu contains items that don’t apply here and should be removed.
Add range checking for the Fahrenheit temperature control. Absolute zero is around –459.6 degrees Fahrenheit.
Add conversion from Celsius to Fahrenheit.
Last updated: 2008-06-05