You are previewing iPhone™ Application Development for Dummies®.
O'Reilly logo
iPhone™ Application Development for Dummies®

Book Description

Here's the fun and easy way to learn how to create your own iPhone applications

Whether you're a professional developer or an iPhone user with a knack for technology, this plain English guide shows you how easy it can be to create your own cool iPhone and iPod touch apps. The open iPhone SDK offers a world of opportunities, and with the information in iPhone Application Development For Dummies, you can get in on the fun and profit.

You don't need high-level programming skills to create iPhone apps. iPhone Application Development For Dummies walks you through the fundamentals for building a variety of applications using Objective-C and covers the critical steps for creating applications that get accepted into the AppStore.

  • Apple's open SDK for the iPhone allows any developer to create iPhone applications

  • This guide helps you develop new applications for use on your own iPhone or for release to other iPhone and iPod Touch users

  • Covers small and large-scale application development

  • Shows how to develop usingObjective-C

  • Enables both novice and experienced programmers to leverage the marketing power of the open iPhone SDK

The iPhone is the hottest smart phone around, and with iPhone Application Development For Dummies, you can create cool new apps to make it even more exciting.

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. Publisher's Acknowledgments
  5. Introduction
    1. About This Book
    2. Conventions Used in This Book
    3. Foolish Assumptions
    4. How This Book Is Organized
      1. Part I: Getting Started
      2. Part II: Using the iPhone Development Tools
      3. Part III: From "Gee, That's a Good Idea" to the App Store
      4. Part IV: An Industrial-Strength Application
      5. Part V: The Part of Tens
    5. Icons Used in This Book
    6. Where to Go From Here
  6. I. Getting Started
    1. 1. Creating Killer iPhone Applications
      1. 1.1. What Makes a Great iPhone Application
      2. 1.2. Creating a Compelling User Experience
      3. 1.3. Exploiting the Platform
        1. 1.3.1. Device-guided design
        2. 1.3.2. Exploiting the features
          1. 1.3.2.1. Accessing the Internet
          2. 1.3.2.2. Knowing the location of the user
          3. 1.3.2.3. Tracking orientation and motion
          4. 1.3.2.4. Tracking the action of the user's fingers on the screen
          5. 1.3.2.5. Playing audio and video
          6. 1.3.2.6. Accessing the user's contacts
          7. 1.3.2.7. Accessing the user's pictures and camera
        3. 1.3.3. Embracing the limitations
          1. 1.3.3.1. Living with the small screen
          2. 1.3.3.2. Designing for fingers
          3. 1.3.3.3. Limited computer power, memory, and battery life
      4. 1.4. A Compelling User Experience
        1. 1.4.1. Compelling content
          1. 1.4.1.1. Consistency with the user's world
        2. 1.4.2. The user interface — form following function
          1. 1.4.2.1. Consistency
          2. 1.4.2.2. Making it obvious
          3. 1.4.2.3. Engaging the user
      5. 1.5. Why Develop iPhone Applications?
      6. 1.6. Examining the Possibilities
      7. 1.7. The Sample Applications
      8. 1.8. What's Next
    2. 2. Looking Behind the Screen
      1. 2.1. Using Frameworks
      2. 2.2. Using Design Patterns
        1. 2.2.1. The Model-View-Controller (MVC) pattern
        2. 2.2.2. The MVC in action
      3. 2.3. Working with Windows and Views
        1. 2.3.1. Looking out the window
        2. 2.3.2. Admiring the view
          1. 2.3.2.1. What views do
          2. 2.3.2.2. The view hierarchy
        3. 2.3.3. The kinds of views you use
          1. 2.3.3.1. Container views
          2. 2.3.3.2. Controls
          3. 2.3.3.3. Display views
          4. 2.3.3.4. Text and Web views
          5. 2.3.3.5. Alert views and action sheets
          6. 2.3.3.6. Navigation views
          7. 2.3.3.7. The window
      4. 2.4. Controlling View Controllers
      5. 2.5. What About the Model?
      6. 2.6. Adding Your Own Application's Behavior
        1. 2.6.1. The Delegation pattern
        2. 2.6.2. The Target-Action pattern
      7. 2.7. Doing What When?
      8. 2.8. Whew
    3. 3. Enlisting in the Developer Corps
      1. 3.1. Becoming a Registered iPhone Developer
      2. 3.2. Exploring the iPhone Dev Center
        1. 3.2.1. Looking forward to using the SDK
        2. 3.2.2. Resources on the iPhone Dev Center
      3. 3.3. Downloading the SDK
      4. 3.4. Joining the iPhone Developer Program
      5. 3.5. Getting Yourself Ready for the SDK
  7. II. Using the iPhone Development Tools
    1. 4. Getting to Know the SDK
      1. 4.1. Developing Using the SDK
      2. 4.2. Creating Your Project
      3. 4.3. Exploring Your Project
      4. 4.4. Building and Running Your Application
      5. 4.5. The iPhone Simulator
        1. 4.5.1. Hardware interaction
        2. 4.5.2. Gestures
        3. 4.5.3. Uninstalling applications and resetting your device
        4. 4.5.4. Limitations
      6. 4.6. Using Interface Builder
      7. 4.7. It's Time to Get to Work
    2. 5. Building the User Interface
      1. 5.1. Starting Interface Builder
      2. 5.2. Adding Graphics and the Rest of the Elements
      3. 5.3. Adding an Application Icon
      4. 5.4. A Lot Accomplished Very Quickly
    3. 6. While Your Application Is Running
      1. 6.1. Application Anatomy 101 — The Life Cycle
        1. 6.1.1. It all starts with the main nib file
        2. 6.1.2. Initialization
      2. 6.2. Event Processing
      3. 6.3. Termination
      4. 6.4. Other Runtime Considerations
        1. 6.4.1. Responding to interruptions
        2. 6.4.2. Seeing how memory management works on the iPhone
          1. 6.4.2.1. Observing low-memory warnings
          2. 6.4.2.2. Avoiding the warnings
          3. 6.4.2.3. Some basic memory-management rules you shouldn't forget
          4. 6.4.2.4. Reread this section
      5. 6.5. Whew!
  8. III. From "Gee, That's a Good Idea" to the App Store
    1. 7. Actually Writing Code
      1. 7.1. Buckle Up, It's Time to Code
      2. 7.2. The Xcode Code Editor
        1. 7.2.1. Using Code Completion
        2. 7.2.2. Accessing API documentation
      3. 7.3. Adding Outlets to the View Controller
        1. 7.3.1. Objective-C properties
      4. 7.4. Memory Management
      5. 7.5. Connecting the Pieces in Interface Builder
    2. 8. Entering and Managing Data
      1. 8.1. Scrolling the View
      2. 8.2. Where Does My Code Go?
        1. 8.2.1. The Delegate object
        2. 8.2.2. The Controller object
      3. 8.3. Where I Am Starting From
      4. 8.4. Building on a Foundation
        1. 8.4.1. Notification
          1. 8.4.1.1. Registering a notification
          2. 8.4.1.2. Unregistering a notification
        2. 8.4.2. Keeping the text field visible
          1. 8.4.2.1. The concept
          2. 8.4.2.2. The mechanics of scrolling the view
        3. 8.4.3. Moving the view
        4. 8.4.4. Updating the interface
        5. 8.4.5. Lowering the view when all is said and done
      5. 8.5. Polishing the Chrome and Adding the Vinyl Pinstriping
        1. 8.5.1. Adopting a protocol
        2. 8.5.2. Connecting things up with Interface Builder
        3. 8.5.3. Adding a Clear button
        4. 8.5.4. Saving the phone number for future reference
        5. 8.5.5. Dismissing the keyboard when the user touches in the view
      6. 8.6. Finding Your Way Around the Code
      7. 8.7. When You're Done
    3. 9. Saving Data and Creating a Secret Button
      1. 9.1. Saving User-Entry Data
        1. 9.1.1. Preferences
          1. 9.1.1.1. The NSUserDefaults class
        2. 9.1.2. Saving data using NSUserDefaults
          1. 9.1.2.1. Setting it up
          2. 9.1.2.2. Saving the phone number
          3. 9.1.2.3. Loading the preference entry to get the data
          4. 9.1.2.4. Using Saved Data
      2. 9.2. Disabling Editing
      3. 9.3. Letting the User Use the Secret Button
      4. 9.4. What You Have Now — At Long Last
    4. 10. Using the Debugger
      1. 10.1. Using the Debugger
        1. 10.1.1. Prepping your project for debugging
        2. 10.1.2. Using the Debugger window
      2. 10.2. Using Breakpoints
      3. 10.3. One More Step
    5. 11. Buttoning It Down and Calling Home
      1. 11.1. Adding a Button to Your iPhone Interface
        1. 11.1.1. The Target-Action pattern
        2. 11.1.2. Working through your button code
      2. 11.2. Connecting the Button in Interface Builder
      3. 11.3. Phoning Home
        1. 11.3.1. Tweaking the code
        2. 11.3.2. Implementing the Web view
        3. 11.3.3. Adding and connecting the Web view in Interface Builder
      4. 11.4. A Bug
      5. 11.5. We Are Finally Done
      6. 11.6. The Final Code
    6. 12. Checking Your Code Using Xcode's Instruments Application
      1. 12.1. The Instruments Application
        1. 12.1.1. The ObjectAlloc instrument
        2. 12.1.2. Using the Leaks instrument
      2. 12.2. Running Instruments on the iPhone
      3. 12.3. Yes, I Am Finally Done
    7. 13. Death, Taxes, and the iPhone Provisioning
      1. 13.1. How the Process Works
      2. 13.2. Provisioning Your Device for Development
        1. 13.2.1. Development Provisioning Profile and iPhone Development Certificate
      3. 13.3. Provisioning Your Application for the App Store
      4. 13.4. iTunes Connect
        1. 13.4.1. What you'll need to get your application into the App Store
        2. 13.4.2. We're not done yet
        3. 13.4.3. Uploading your information
        4. 13.4.4. Upload your application and its data
      5. 13.5. Now What?
  9. IV. An Industrial-Strength Application
    1. 14. Designing Your Application
      1. 14.1. Defining the Problems
      2. 14.2. Designing the User Experience
        1. 14.2.1. Defining the constraints
        2. 14.2.2. Categorizing the problems and defining the solutions
      3. 14.3. Creating the Program Architecture
        1. 14.3.1. A main view
        2. 14.3.2. Content views
        3. 14.3.3. View controllers
        4. 14.3.4. Models
          1. 14.3.4.1. No use re-inventing the wheel
          2. 14.3.4.2. Putting property lists to good use
        5. 14.3.5. Stored data mode, saving state, and localization
      4. 14.4. The Iterative Nature of the Process
    2. 15. Setting the Table
      1. 15.1. Working with Table Views
        1. 15.1.1. Creating the table view
        2. 15.1.2. Creating and formatting a grouped table view
        3. 15.1.3. Making UITableViewController work for you
          1. 15.1.3.1. Adding sections
          2. 15.1.3.2. Adding titles for the sections
          3. 15.1.3.3. Localization
        4. 15.1.4. Creating the model
        5. 15.1.5. Seeing how cells work
          1. 15.1.5.1. Using vanilla cell objects
          2. 15.1.5.2. Adding subviews to a cell's content view
          3. 15.1.5.3. Creating a custom subclass UITableViewCell
        6. 15.1.6. Creating the cell
        7. 15.1.7. Responding to a selection
        8. 15.1.8. Navigating the navigation controller
        9. 15.1.9. Implementing the selection
      2. 15.2. And now ...
    3. 16. Enhancing the User Experience
      1. 16.1. Saving and Restoring State
        1. 16.1.1. Saving state information
        2. 16.1.2. Restoring the state
      2. 16.2. Respecting User Preferences
        1. 16.2.1. Adding a Settings bundle to your project
        2. 16.2.2. Setting up the property list
      3. 16.3. Reading Settings in the Application
      4. 16.4. This App Is Almost Done
    4. 17. Creating Controllers and Their Models
      1. 17.1. Specifying the Content
      2. 17.2. Creating the View Controller, Nib, and Model Files
        1. 17.2.1. Adding the controller and nib file
        2. 17.2.2. Set up the nib file
        3. 17.2.3. Adding the model class
      3. 17.3. Implementing the View, View Controller, and the Model
        1. 17.3.1. The initialization chain
        2. 17.3.2. Setting up the view
        3. 17.3.3. Responding to the user selection
      4. 17.4. The Airport Model
      5. 17.5. The Weather Implementation Model
      6. 17.6. The Currency Implementation Model
      7. 17.7. What About That Promise You Made Us
      8. 17.8. What's Next?
  10. V. The Part of Tens
    1. 18. Top Ten Sample Apple Apps (with Code!)
      1. 18.1. AppPrefs
      2. 18.2. BubbleLevel
      3. 18.3. LocateMe
      4. 18.4. NavBar
      5. 18.5. Reachability
      6. 18.6. SQLite Book List
      7. 18.7. UICatalog
      8. 18.8. URLCache
      9. 18.9. XML
      10. 18.10. Tables
    2. 19. Ten Ways to Be a Happy Developer
      1. 19.1. It's Never Early Enough to Start Speaking a Foreign Language
      2. 19.2. Remember Memory
      3. 19.3. Constantly Use Constants
      4. 19.4. Don't Fall Off the Cutting Edge
      5. 19.5. Start by Initializing the Right Way
      6. 19.6. Keep the Order Straight
      7. 19.7. Avoid Mistakes in Error Handling
      8. 19.8. Remember the User
      9. 19.9. Keep In Mind that the Software Isn't Finished Until The Last User Is Dead
      10. 19.10. Keep It Fun