Cover image for Learning iPhone Programming

Book description

Get the hands-on experience you need to program for the iPhone and iPod touch. With this easy-to-follow guide, you'll learn how to use Xcode tools, the Objective-C programming language, and the core frameworks by writing a number of sample apps. Before you know it, you'll not only have the skills to develop your own apps, you'll also be ready to handle the complex details of preparing and submitting apps to Apple's App Store. Learning iPhone Programming helps you through the genuinely tricky process involved in developing apps for Apple's popular devices. Whether you're a developer new to Mac programming, or an experienced Mac developer ready to tackle the iPhone and iPod Touch, this book will take you from Xcode to the App Store.

  • Start using Xcode right away, and learn how to work with Interface Builder

  • Take advantage of model-view-controller architecture with Objective-C

  • Build a data-entry interface, and learn how to parse and store the data you receive

  • Solve typical problems while building a variety of challenging sample apps

  • Understand the demands and details of App Store and ad hoc distribution

  • Discover how to use iPhone's accelerometer, proximity sensor, GPS, digital compass, and camera

  • Learn how to integrate your app with iPhone's preference pane, media playback, and more

This book is still in progress, but you can get going on iPhone development through our Rough Cuts edition, which lets you read the manuscript as it's being written , either online or via PDF.

Table of Contents

  1. Learning iPhone Programming
    1. SPECIAL OFFER: Upgrade this ebook with O’Reilly
    2. A Note Regarding Supplemental Files
    3. Preface
      1. Who Should Read This Book?
      2. What Should You Already Know?
      3. What Will You Learn?
      4. What’s in This Book?
      5. Conventions Used in This Book
      6. Using Code Examples
      7. How to Contact Us
      8. Safari® Books Online
      9. Acknowledgments
    4. 1. Why Go Native?
      1. The Pros and Cons
        1. Why Write Native Applications?
      2. The Release Cycle
      3. Build It and They Will Come
    5. 2. Becoming a Developer
      1. Registering As an iPhone Developer
      2. Enrolling in the iPhone Developer Program
      3. The Apple Developer Connection
      4. Installing the iPhone SDK
      5. Preparing Your iPhone or iPod touch
        1. Creating a Development Certificate
        2. Getting the UDID of Your Development Device
        3. Creating an App ID
        4. Creating a Mobile Provisioning Profile
        5. Making Your Device Available for Development
    6. 3. Your First iPhone App
      1. Objective-C Basics
        1. Object-Oriented Programming
        2. The Objective-C Object Model
        3. The Basics of Objective-C Syntax
      2. Creating a Project
        1. Exploring the Project in Xcode
          1. Overview of an iPhone application
          2. The application delegate
          3. The view controller
        2. Our Project in Interface Builder
        3. Adding Code
        4. Connecting the Outlets in Interface Builder
        5. Putting the Application on Your iPhone
    7. 4. Coding in Objective-C
      1. Declaring and Defining Classes
        1. Declaring a Class with the Interface
        2. Defining a Class with the Implementation
        3. Object Typing
        4. Properties
        5. Synthesizing Properties
        6. The Dot Syntax
        7. Declaring Methods
        8. Calling Methods
        9. Calling Methods on nil
      2. Memory Management
        1. Creating Objects
        2. The Autorelease Pool
        3. The alloc, retain, copy, and release Cycle
        4. The dealloc Method
        5. Responding to Memory Warnings
      3. Fundamental iPhone Design Patterns
        1. The Model-View-Controller Pattern
        2. Views and View Controllers
        3. The Delegates and DataSource Pattern
      4. Conclusion
    8. 5. Table-View-Based Applications
      1. Simplifying the Template Classes
      2. Creating a Table View
        1. Organizing and Navigating Your Source Code
        2. Connecting the Outlets
      3. Building a Model
        1. Adding Images to Your Projects
      4. Connecting the Controller to the Model
        1. Mocking Up Functionality with Alert Windows
      5. Adding Navigation Controls to the Application
      6. Adding a City View
      7. Edit Mode
        1. Deleting a City Entry
        2. Adding a City Entry
        3. The “Add New City...” Interface
        4. Capturing the City Data
    9. 6. Other View Controllers
      1. Utility Applications
        1. Making the Battery Monitoring Application
          1. Building our interface
          2. Writing the code
          3. Wiring the application in Interface Builder
      2. Tab Bar Applications
        1. Refactoring the Template
          1. Creating the first tab
          2. Creating the second tab
          3. Wrapping up the refactoring
        2. Adding Another Tab Bar Item
        3. Finishing Up
      3. Modal View Controllers
        1. Modifying the City Guide Application
      4. The Image Picker View Controller
        1. Adding the Image Picker to the City Guide Application
    10. 7. Connecting to the Network
      1. Detecting Network Status
        1. Apple’s Reachability Class
          1. Synchronous reachability
          2. Asynchronous reachability
          3. Using Reachability directly
      2. Embedding a Web Browser in Your App
        1. A Simple Web View Controller
        2. Displaying Static HTML Files
        3. Getting Data Out of a UIWebView
      3. Sending Email
      4. Getting Data from the Internet
        1. Synchronous Requests
        2. Asynchronous Requests
        3. Using Web Services
          1. The Google Weather Service
          2. Building an application
          3. Parsing the XML document
          4. Populating the UI
          5. Tidying up
    11. 8. Handling Data
      1. Data Entry
        1. UITextField and Its Delegate
        2. UITextView and Its Delegate
          1. Dismissing the UITextView
      2. Parsing XML
        1. Parsing XML with libxml2
        2. Parsing XML with NSXMLParser
      3. Parsing JSON
        1. The Twitter Search Service
        2. The Twitter Trends Application
          1. Refactoring
          2. Retrieving the trends
          3. Building a UI
          4. Parsing the JSON document
          5. Tidying up
      4. Regular Expressions
        1. Introduction to Regular Expressions
          1. RegexKitLite
          2. Faking regex support with the built-in NSPredicate
      5. Storing Data
        1. Using Flat Files
          1. Reading and writing text content
          2. Creating temporary files
          3. Other file manipulation
        2. Storing Information in an SQL Database
          1. Adding a database to your project
          2. Data persistence for the City Guide application
          3. Refactoring and rethinking
        3. Core Data
    12. 9. Distributing Your Application
      1. Adding Missing Features
        1. Adding an Icon
        2. Adding a Launch Image
        3. Changing the Display Name
        4. Enabling Rotation
      2. Building and Signing
        1. Ad Hoc Distribution
          1. Obtaining a distribution certificate
          2. Registering devices
          3. Creating a provisioning profile
          4. Building your application for ad hoc distribution
          5. Distributing an ad hoc build
        2. Developer-to-Developer Distribution
        3. App Store Distribution
          1. Building your application for App Store distribution
      3. Submitting to the App Store
        1. The App Store Resource Center
      4. Reasons for Rejection
    13. 10. Using Sensors
      1. Hardware Support
        1. Determining Available Hardware Support
          1. Network availability
          2. Camera availability
          3. Audio input availability
          4. GPS availability
        2. Setting Required Hardware Capabilities
      2. Using the Camera
      3. The Core Location Framework
        1. Location-Dependent Weather
          1. Using the GeoNames reverse geocoding service
          2. Modifying the Weather application
          3. Tidying up
      4. Using the Accelerometer
        1. Writing an Accelerometer Application
      5. Using the Digital Compass
      6. Accessing the Proximity Sensor
      7. Using Vibration
    14. 11. Geolocation and Mapping
      1. User Location
      2. Annotating Maps
    15. 12. Integrating Your Application
      1. Application Preferences
        1. Accessing Global Preferences
      2. Custom URL Schemes
        1. Using Custom Schemes
          1. Making a telephone call
          2. Sending an SMS message
        2. Registering Custom Schemes
      3. Media Playback
      4. Using the Address Book
        1. Interactive People Picking
        2. Programmatic People Picking
    16. 13. Other Native Platforms
      1. PhoneGap
        1. Download and Installation
        2. Building a PhoneGap Project
      2. MonoTouch
        1. Download and Installation
        2. Building a MonoTouch Project
    17. 14. Going Further
      1. Cocoa and Objective-C
        1. The iPhone SDK
      2. Web Applications
      3. Core Data
      4. Push Notifications
      5. In-App Purchase
      6. Core Animation
      7. Game Kit
      8. Writing Games
      9. Look and Feel
      10. Hardware Accessories
    18. Index
    19. About the Author
    20. Colophon
    21. SPECIAL OFFER: Upgrade this ebook with O’Reilly