Chapter 3

Giving Your App Something to Do

In This Chapter

arrow Developing a useful app

arrow Personalizing Xcode

Here I introduce to you one approach you can take for connecting your app’s UI elements with the code that your app executes when it operates on the data that your users enter into the UI. This approach is explicit — you’ll be adding all the code and making the connections yourself. Xcode 4 provides another approach as well, which I introduce after I walk you down the more explicit path.

Creating a Tip Calculator

Here’s where I demonstrate the interaction between the UI and the code through a very simple example: I turn SimpleCocoaWindowApp (as demonstrated in Chapter 2) into a tip calculator with the following steps.

1. Select SimpleCocoaWindowAppAppDelegate.h in the Project navigator.

This is the header file for our class, and it looks pretty bare-bones. The header file contains declarations of the parts of a class — this file can be #imported into other source modules as a “promise” of what the class provides. You’re going to add some UI controls to the window, and this is the place to do it.

2. Enter the purple-colored text shown in Listing 3-1.

I’m going to use purple to highlight the new code to add. You’re adding four member variables and one new method. The member ...

Get Mac® Application Development For Dummies® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.