Getting Started: Building the Calculator Project

Một phần của tài liệu building cocoa applications - a step-by-step guide (2002) (Trang 190 - 195)

Part II: Calculator: Building a Simple Application

Chapter 5. Building a Project: A Four-Function

5.1 Getting Started: Building the Calculator Project

Follow these steps carefully to get started building your Calculator project:

1. Make sure that the Project Builder and Interface Builder icons are in your dock, then launch PB from your Dock.

2. Choose Project Builder Hide Others to simplify your screen.

3. Choose PB's File New Project menu command to begin the process of

creating a new project (see Figure 5-2). The New Project Assistant dialog opens, as shown in Figure 5-3.

Figure 5-2. Choose PB's File New Project command to create a new project

Figure 5-3. New Project Assistant in PB

4. Make sure that Cocoa Application is highlighted, as shown in Figure 5-3, then click Next. The New Cocoa Application dialog shows up, as shown in Figure 5-4.

Figure 5-4. Providing the name and location for a project

5. Type "Calculator" in the Project Name field of the New Cocoa Application panel, as shown in Figure 5-4.

6. Hit the Tab key to fill in the second line, as shown in Figure 5-4, and click the Finish button.

PB's main window for the Calculator project opens; it should look similar to the window in Figure 5-5.

Figure 5-5. Main window in PB

The main window in PB contains several buttons. The four buttons that look like tools (hammer, whiskbroom, etc.) at the left of the window just below its title bar are "action"

buttons that can build, clean, run, and debug your project. The five disabled (dimmed) buttons near the top-right corner of the window are used with the debugger (as discussed in Section 2.4.1 in Chapter 2). Going from left to right, these debug buttons allow you to pause execution, continue execution, step over the method or function call, step into the method or function call, and step out of the current method or function call. Descriptions of the buttons pop up as you move the mouse over them.

The rest of the PB main window is divided into two sets of tabbed views. The vertical set of tabs controls what is seen in the lefthand pane of the window.

This pane (or view) can display one of five different types of information:

● The files in your project

● The classes in your project

● The bookmarks that you have set in your project

● The build targets

● Any debugging breakpoints that you may have set

The horizontal tabs near the righthand side of PB's main window display either the Find feature, the Build output, the Run (logged) output, or the Debugger output in the pane that opens above the tabs. Finally, the lower-right corner of PB's main window is where you can browse or edit a file. The first file that is displayed when you create a new project is the Project Builder Release Notes. Normally, you would edit your source code or display Help or AppKit headers in this (text) pane.

When you first see PB's main window, the Files tab is highlighted and groups for five types of files (Classes, Other Sources, etc.) associated with your project are shown. You can click the little gray disclosure triangles next to the labels in this Groups & Files pane to show the names of the files in your project. We'll discuss these different file types later, in Section 5.10.

7. Click the disclosure triangle to the left of the Resources label in the Groups & Files pane to reveal the MainMenu.nib and InfoPlist.strings files, as shown in Figure 5-5.

The checks next to these files in the target column at the left of PB's main window mean that the files are part of the Calculator target.

8. Double-click the MainMenu.nib file icon in PB's main window.

IB will launch and display the MainMenu.nib interface that was automatically created by PB when we created a new Cocoa application. This interface includes a main menu titled "MainMenu" and a main window titled "Window". An associated Nib File window is also displayed in the lower-left corner of the screen, below the new menu.

9. To simplify the screen, choose Interface Builder Hide Others.

Your screen should contain the same objects as the one shown in Figure 5-6 (although probably not in the exact same location, and the Palettes window may show a different palette).

Figure 5-6. IB with the MainMenu.nib file for the Calculator project opened

Book: Building Cocoa Applications: A Step-by-Step Guide Section: Chapter 5. Building a Project: A Four-Function Calculator

Một phần của tài liệu building cocoa applications - a step-by-step guide (2002) (Trang 190 - 195)

Tải bản đầy đủ (PDF)

(727 trang)