Moon Travel Planner: Displaying Localized Text
According to our specification (see Chapter 2), the Moon Travel Planner application needs a window, Facts for the Traveller, that displays facts about the moon to entice travelers to visit. The list of facts is a perfect candidate for a Localizable.strings
file.
You’ll need to do the following to create the window:
Create a new window to display the facts.
Add a text field.
Create a
Localizable.strings
file and add content for the window.Write a function to display the text.
Modify the main window event handler so it handles the command that opens the facts window.
Write a handler for the moon facts window. You need this handler to close the window. Later, you’ll need the handler to take care of print commands. (Recall that the specification calls for this window to be printable. You’ll write the printing code in Chapter 9.)
Make sure text displays properly in the window.
Create a New Window
There are two ways you can use Interface Builder to create a new window: add a window to the existing main.nib
file or create a new nib file for the window. In this section you’ll
add a window to the existing nib file. Later, in Chapter 11
you’ll learn how to create a new nib file for a window.
Double-click the
main.nib
file in the Moon Travel Planner project.Create a new window. Click the Windows button in the Palette toolbar. Then drag the window icon from the left side of the palette to the desktop, as shown in Figure 8.4.
Name the window object ...
Get Learning Carbon 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.