O'Reilly logo

Mac® Application Development For Dummies® by Karl G. Kowalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required