Learning iOS Programming, 3rd Edition

Book description

Get a rapid introduction to iPhone, iPad, and iPod touch programming. With this easy-to-follow guide, you’ll learn how to develop your first marketable iOS application, from opening Xcode to submitting your product to the App Store. Whether you’re a developer new to Mac programming or an experienced Mac developer ready to tackle iOS, this is your book.

You’ll learn about Objective-C and the core frameworks hands-on by writing several sample iOS applications, giving you the basic skills for building your own applications independently. Packed with code samples, this book is refreshed and updated for iOS 6 and Xcode 4.

  • Discover the advantages of building native iOS apps
  • Get started with Objective-C and the Cocoa Touch frameworks
  • Dive deep into the table view classes for building user interfaces
  • Handle data input, parse XML and JSON documents, and store data on SQLite
  • Use iOS sensors, including the accelerometer, magnetometer, camera, and GPS
  • Build apps that use the Core Location and MapKit frameworks
  • Integrate Apple’s iCloud service into your applications
  • Walk through the process of distributing your polished app to the App Store

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Third Edition
    2. Notes from the Second Edition
    3. Who Should Read This Book?
    4. What Should You Already Know?
    5. What Will You Learn?
    6. What’s in This Book?
    7. Conventions Used in This Book
    8. Using Code Examples
    9. How to Contact Us
    10. Safari® Books Online
    11. Acknowledgments
  2. 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
  3. 2. Becoming a Developer
    1. Registering as an iOS Developer
    2. Enrolling in the iOS Developer Program
    3. The Mac Developer Program
    4. Installing the iOS SDK
      1. What Happens When There Is a Beta?
    5. Preparing Your iOS Device
      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
  4. 3. Your First iOS 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. Building the User Interface
      4. Connecting the User Interface to the Code
      5. Running the Application in the Simulator
      6. Putting the Application on Your iPhone
  5. 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. Automatic Reference Counting
      5. The dealloc Method
      6. Responding to Memory Warnings
    3. Fundamental iOS Design Patterns
      1. The Model-View-Controller Pattern
      2. Views and View Controllers
      3. The Delegates and DataSource Pattern
    4. Conclusion
  6. 5. Table View-Based Applications
    1. Creating the Project
    2. Creating a Table View
      1. Running the Code
    3. Populating the Table View
    4. Building a Model
      1. Adding Cities to the Guide
      2. Adding Images to Your Projects
    5. Connecting the Controller to the Model
      1. Mocking Up Functionality with Alert Windows
    6. Adding Navigation Controls to the Application
    7. Adding a City View
    8. Edit Mode
      1. Deleting a City Entry
      2. Adding a City Entry
      3. The “Add New City” Interface
      4. Capturing the City Data
  7. 6. Other View Controllers
    1. Utility Applications
      1. Making the Battery Monitoring Application
        1. Building the interface
        2. Writing the code
    2. Tab Bar Applications
      1. Adding Another Tab Bar Item
    3. Combining View Controllers
    4. Modal View Controllers
      1. Modifying the City Guide Application
    5. The Image Picker View Controller
      1. Adding the Image Picker to the City Guide Application
    6. Master-Detail Applications
      1. Creating a Universal Application
    7. Popover Controllers
  8. 7. Connecting to the Network
    1. Detecting Network Status
      1. Apple’s Reachability Class
        1. Reusing the Reachability class
        2. Synchronous Reachability
        3. Asynchronous reachability
        4. Using Reachability directly
        5. Updating the Reachability project
    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 Weather Underground service
        2. Building an application
        3. Parsing the XML document
        4. Populating the UI
        5. Tidying up
  9. 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. NSJSONSerialization
        1. Parsing JSON documents
        2. Creating JSON documents
      2. The JSON Framework
      3. Retrieving Twitter Trends
      4. Using the Social Framework
      5. The Twitter Trends Application
        1. Retrieving the trends
        2. Building a UI
        3. Parsing the JSON document
        4. Tidying up
    4. Regular Expressions
      1. Introduction to Regular Expressions
        1. NSRegularExpression
        2. RegexKitLite
        3. 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 a SQL Database
        1. Adding a database to your project
        2. Data persistence for the City Guide application
        3. Refactoring and rethinking
      3. Core Data
  10. 9. Using Sensors
    1. Hardware Support
      1. Network Availability
      2. Camera Availability
      3. Audio Input Availability
      4. GPS Availability
      5. Magnetometer Availability
    2. Setting Required Hardware Capabilities
      1. Persistent WiFi
      2. Background Modes
    3. Differences Between iPhone and iPad
    4. Using the Camera
    5. The Core Motion Framework
      1. Pulling Motion Data
      2. Pushing Motion Data
      3. The Accelerometer
        1. Using the accelerometer directly
      4. The Gyroscope
        1. Using the gyroscope directly
      5. The Magnetometer
        1. Using the magnetometer directly
    6. Accessing the Proximity Sensor
    7. Using Vibration
  11. 10. Geolocation and Mapping
    1. The Core Location Framework
      1. Device Heading
    2. Location-Dependent Weather
      1. Reverse Geocoding
      2. Forward Geocoding
      3. CLPlacemark Objects
      4. Modifying the Weather Application
    3. User Location and MapKit
    4. Annotating Maps
  12. 11. Introduction to iCloud
    1. How Can I Use iCloud?
      1. iCloud Backup
      2. Provisioning Your Application for iCloud
    2. Using Key-Value Storage
    3. Wrapping Up
  13. 12. Integrating Your Application
    1. Application Preferences
    2. The Accounts Framework
    3. The Social Framework
      1. Sending Tweets
      2. Making Posts to Facebook
    4. Custom URL Schemes
      1. Using Custom Schemes
        1. Making a telephone call
        2. Opening the Settings application
      2. Registering Custom Schemes
    5. Media Playback
    6. Using the Address Book
      1. Interactive People Picking
      2. Programmatic People Picking
    7. Sending Text Messages
  14. 13. 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
    3. Submitting to the App Store
      1. Building Your Application for App Store Distribution
      2. The App Store Resource Center
    4. Reasons for Rejection
  15. 14. Going Further
    1. Cocoa and Objective-C
      1. The iOS SDK
    2. Web Applications
      1. PhoneGap
    3. Core Data
    4. In-App Purchase
      1. MKStoreKit
    5. Core Animation
    6. Game Kit
    7. Writing Games
    8. Look and Feel
    9. Hardware Accessories
  16. Index
  17. About the Author
  18. Colophon
  19. Copyright

Product information

  • Title: Learning iOS Programming, 3rd Edition
  • Author(s): Alasdair Allan
  • Release date: March 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449359348