Home > Store

iPhone for Programmers: An App-Driven Approach

Register your product to gain access to bonus material or receive a coupon.

iPhone for Programmers: An App-Driven Approach


  • Sorry, this book is no longer in print.
Not for Sale



  • This book takes an application driven approach to  iPhone programming.  It does not assume any prior knowledge of Objective-C or Cocoa or of Apple’s programming tools.  Most importantly, it does NOT teach through a conventional walk-through of the objects, methods, and properties available to the iPhone developer.  Instead, it teaches by doing:
  • Developers study  touches and gestures through building the Spot-On game application - where the user must touch circles as they appear, while not removing fingers from previous circles. Introduces subclassing UIView and creating subviews. Also introduces multi-touch events and basic features of Core Animation.
  • Developers learn about location-based programming through the Take Me Home App, where the user enters a home address and one tab displays an arrow pointing towards the user's home, and the other displays directions for how to get there. Discusses the Core Location framework and the new iPhone Google Maps API.
  • The Twitter App is an application that reads and filters Twitter feeds. It introduces Internet network programming concepts.
  • The Address Book App-which displays a list of contacts and allows the user to update the list--teaches developers  about tables and the UINavigationController. It introduces several types of table views along with the navigation controller.


  • Copyright 2010
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-705842-X
  • ISBN-13: 978-0-13-705842-6

The professional programmer’s DEITEL® guide to iPhone app development using iPhone SDK 3.x, Xcode®, Objective-C® and Cocoa®

More than 1.5 billion iPhone apps were downloaded from Apple’s App Store in just one year! This book gives you everything you’ll need to start developing great iPhone apps quickly and–once you’ve joined Apple’s fee-based iPhone Developer Program–to get them up and running on the App Store. The book uses an app-driven approach–each new technology is discussed in the context of 14 fully tested iPhone apps (7700 lines of code), complete with syntax shading, code walkthroughs and sample outputs. Apps you’ll develop include:

  • Welcome
  • Spot-On Game
  • Route Tracker
  • Tip Calculator
  • Cannon Game
  • Slideshow
  • Favorite Twitter® Searches
  • Painter
  • Voice Recorder
  • Flag Quiz Game
  • Address Book
  • Twitter® Discount Airfares
By Chapter 3 you’ll be building apps using Xcode®, Cocoa® and Interface Builder. You’ll learn object-oriented programming in Objective-C® and build apps using the latest iPhone 3.x technologies including the Game Kit, iPod library access and more.

iPhone for Programmers include practical, example-rich coverage of:

• iPhone SDK 3.x, XCode®, Interface Builder

• Object-Oriented Programming in Objective-C® and Cocoa®

• Collections, GUI, Event Handling

• Controllers, Application Templates

• UIView, Multi-Touch™

• Core Audio, Core Animation, NSTimer

• Tables, UINavigationController

• Map Kit, Core Location, GPS, Compass

• Photos, iPod Library Access

• Serialization



Download the examples

Sample Content

Table of Contents

Illustrations          xvii
Preface          xxvii
Before You Begin          xxxiii

Chapter 1:  Introduction to iPhone App Development          1
1.1    Introduction to iPhone for Programmers  2
1.2    iPhone Overview  3
1.3    Key New iPhone 3GS and OS 3.x Features and Enhancements  6
1.4    Downloading Apps from the App Store  7
1.5    iPhone OS 3.x  8
1.6    Objective-C Programming Language  9
1.7    Design Patterns  10
1.8    Cocoa Frameworks  11
1.9    New iPhone SDK 3 Features  13
1.10  Xcode Toolset  14
1.11  Basics of Object Technology  15
1.12  Web 2.0  17
1.13  Test-Driving the Painter App in the iPhone Simulator  17
1.14  Wrap-Up  22
1.15  Deitel Resource Centers  22

Chapter 2:  iPhone App Store and App Business Issues       23
2.1    Introduction  24
2.2    iPhone Developer Program: Setting Up Your Profile for Testing and Submitting Apps  25
2.3    iPhone Human Interface Guidelines  30
2.4    Testing Your App  32
2.5    Preparing Your App for Submission through iTunes Connect  32
2.6    Characteristics of Great iPhone Apps  34
2.7    Avoiding Rejection of Your App  35
2.8    Pricing Your App: Free or Fee  36
2.9    Adding an App to iTunes Connect  38
2.10  Monetizing Paid Apps: Using In App Purchase to Sell Virtual Goods  41
2.11  Using iTunes Connect to Manage Your Apps  42
2.12  Marketing Your App  43
2.13  iPhone Anecdotes and Humor  48
2.14  Other Platforms  49
2.15  iPhone Developer Documentation  50
2.16  Wrap-Up  50

Chapter 3:  Welcome App          51
Dive-Into® Xcode, Cocoa and Interface Builder
3.1  Introduction  52
3.2  Overview of the Technologies  52
3.3  Xcode 3.x IDE and Cocoa  53
3.4  Building the Application  56
3.5  Building the GUI with Interface Builder  57
3.6  Running the Welcome App  61
3.7  Wrap-Up  63

Chapter 4:  Tip Calculator App          64
Introducing Objective-C Programming
4.1  Introduction  65
4.2  Test-Driving the Tip Calculator App  66
4.3  Overview of the Technologies  66
4.4  Building the App  66
4.5  Adding Functionality to Your App  71
4.6  Connecting Objects in Interface Builder  73
4.7  Implementing the Class’s Methods  76
4.8  Wrap-Up  81

Chapter 5:  Favorite Twitter® Searches App          83
Collections and Cocoa GUI Programming
5.1  Introduction  84
5.2  Test-Driving the Favorite Twitter Searches App  85
5.3  Technologies Overview  86
5.4  Building the App  86
5.5  Wrap-Up  101

Chapter 6:  Flag Quiz Game App           102
Controllers and the Utility Application Template
6.1  Introduction  103
6.2  Test-Driving the Flag Quiz Game App  106
6.3  Technologies Overview  106
6.4  Building the App  107
6.5  Wrap-Up  127

Chapter 7:  Spot-On Game App          129
Using UIView and Detecting Touches
7.1  Introduction  130
7.2  Test-Driving the Spot-On Game App  132
7.3  Overview of the Technologies  132
7.4  Building the App  132
7.5  Wrap-Up  147

Chapter 8:  Cannon Game App          154
Animation with NSTimer and Handling Drag Events
8.1  Introduction  155
8.2  Test-Driving the Cannon Game app  156
8.3  Overview of the Technologies  156
8.4  Building the App  157
8.5  Wrap-Up  171

Chapter 9:  Painter App           173
Using Controls with a UIView
9.1  Introduction  174
9.2  Overview of the Technologies  174
9.3  Building the App  175
9.4  Wrap-Up  191

Chapter 10:  Address Book App         193
Tables and UINavigationController
10.1  Introduction  194
10.2  Test-Driving the Address Book App  196
10.3  Technologies Overview  196
10.4  Building the App  197
10.5  Wrap-Up  219

Chapter 11:  Route Tracker App          220
Map Kit and Core Location (GPS and Compass)
11.1  Introduction  221
11.2  Test-Driving the Route Tracker App  224
11.3  Technologies Overview  224
11.4  Building the App  225
11.5  Wrap-Up  238

Chapter 12:  Slideshow App          240
Photos and iPod Library Access
12.1  Introduction  241
12.2  Test-Driving the Slideshow App  244
12.3  Technologies Overview  245
12.4  Building the App  245
12.5  Wrap-Up  276

Chapter 13:  Enhanced Slideshow App          278
Serialization Data with NSCoder and Playing Video
13.1  Introduction  279
13.2  Test-Driving the Enhanced Slideshow App  281
13.3  Overview of the Technologies  282
13.4  Building the App  282
13.5  Suggested Enhancements  309
13.6  Wrap-Up  309

Chapter 14:  Voice Recorder App          310
Audio Recording and Playback
14.1  Introduction  311
14.2  Test-Driving the Voice Recorder App  314
14.3  Overview of the Technologies  314
14.4  Building the App  315
14.5  Speech Synthesis and Recognition  341
14.6  Wrap-Up  341

Chapter 15:  Enhanced Address Book App          342
Managing and Transferring Persistent Data
15.1  Introduction  343
15.2  Test-Driving the Enhanced Address Book App  345
15.3  Technologies Overview  345
15.4  Building the App  346
15.5  Wrap-Up  362

Chapter 16:  Twitter® Discount Airfares App          364
Internet Enabled Applications
16.1  Introduction  365
16.2  Test-Driving the Twitter Discount Airfares App  366
16.3  Technologies Overview  366
16.4  Building the App  366
16.5  Wrap-Up  386

Index  387


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020