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.stringsfile 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.nibfile 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access