iOS Programming: The Big Nerd Ranch Guide, Second Edition

Book description

In this book, the world's leading Apple platform development trainers offer a complete, practical, hands-on introduction to iPhone and iPad programming. The authors walk through all the Apple tools and technologies needed to build successful iPhone/iPad/iPod touch Apps, including the iOS 4.3 SDK, the Objective-C language, Xcode 4 tools, Foundation framework, and the classes that make up the iPhone UI framework. The many topics covered in this book include:

  • Easily setting up elegant, efficient user interfaces with UIKit

  • Creating effective visuals, animation, and effects with Core Graphics, Core Animation, and OpenGL

  • Making the most of the iPhone's powerful multi-touch event handling

  • Building location-aware iPhone applications utilizing Core Location, MapKit, and the magnetometer

  • Localizing applications for international use

  • Creating applications that capture audio and play media

  • Storing data in files or SQLite databases

  • This edition has been updated to cover the iPad. New chapters added to this edition include:

  • UIPopoverController and UISplitViewController

  • Blocks and Categories

  • UIGestureRecognizers and Advanced UIScrollView, CATiledLayer

  • Key-Value Coding and Key-Value Observing

  • Push Notifications

  • Unit Testing

  • Table of contents

    1. Title Page
    2. Acknowledgments
    3. Introduction
      1. Prerequisites
      2. What’s Changed in the Second Edition?
      3. Our Teaching Philosophy
      4. How To Use This Book
      5. Using an eBook
      6. How This Book Is Organized
      7. Style Choices
      8. Typographical Conventions
      9. Necessary Hardware and Software
    4. 1. A Simple iOS Application
      1. Creating an Xcode Project
      2. Building Interfaces
      3. Model-View-Controller
      4. Declarations
        1. Declaring instance variables
        2. Declaring methods
      5. Making Connections
        1. Setting pointers
        2. Setting targets and actions
        3. Summary of connections
      6. Implementing Methods
      7. Build and Run on the Simulator
      8. Deploying an Application
      9. Application Icons
      10. Launch Images
    5. 2. Objective-C
      1. Objects
      2. Using Instances
        1. Creating objects
        2. Sending messages
        3. Destroying objects
      3. Writing the RandomPossessions Tool
        1. NSString
        2. NSArray and NSMutableArray
      4. Subclassing an Objective-C Class
        1. Instance variables
        2. Accessor methods
        3. Instance methods
        4. Initializers
          1. id
          2. isa
          3. Implementing the designated initializer
          4. self
          5. super
        5. Other initializers and the initializer chain
        6. Class methods
        7. Testing your subclass
      5. Exceptions and the Console Window
      6. Fast Enumeration
      7. Challenge
    6. 3. Memory Management
      1. Memory Management Basics
        1. Managing memory in C
        2. Managing memory with objects
      2. Reference Counting
        1. Using retain counts
        2. Using autorelease
        3. Accessors and memory management
        4. Implementing dealloc
        5. Simplifying accessors with properties
        6. copy and mutableCopy
        7. Retain count rules
      3. For the More Curious: More on Memory Management
    7. 4. Delegation and Core Location
      1. Projects, targets, and frameworks
      2. Core Location
        1. Receiving updates from CLLocationManager
      3. Delegation
        1. Protocols
          1. Protocol methods
        2. Delegation, controllers, and memory management
      4. Using the Debugger
      5. Challenge: Heading
      6. For the More Curious: Build Phases, Compiler Errors, and Linker Errors
        1. Preprocessing
        2. Compiling
        3. Linking
    8. 5. MapKit and Text Input
      1. Object Diagrams
      2. MapKit Framework
      3. Interface Properties
      4. Being a MapView Delegate
        1. Using the documentation
        2. Your own MKAnnotation
        3. Tagging locations
        4. Putting the pieces together
      5. Challenge: Annotation Extras
      6. Challenge: Reverse Geocoding
    9. 6. Subclassing UIView
      1. Creating a Custom View
        1. The drawRect: method
        2. Instantiating a UIView
      2. Drawing Text and Shadows
      3. Using UIScrollView
      4. Zooming
      5. Hiding the Status Bar
      6. Challenge: Colors
      7. For the More Curious: Retain Cycles
      8. For the More Curious: Redrawing Views
    10. 7. View Controllers
      1. View Controllers and XIB Files
      2. Using View Controllers
        1. Creating the UITabBarController
        2. Creating view controllers and tab bar items
        3. Creating views for the view controllers
          1. Demystifying the XIB: File's Owner
      3. Appearing and Disappearing Views
      4. The View Controller Lifecycle and Low-Memory Warnings
      5. View Controller Subclasses and Templates
      6. Challenge: Map Tab
    11. 8. The Accelerometer
      1. Setting Up the Accelerometer
      2. Getting Accelerometer Data
      3. Orientation and Scale of Acceleration
      4. Using Accelerometer Data
      5. Smoothing Accelerometer Data
      6. Detecting Shakes
      7. Challenge: Changing Colors
      8. For the More Curious: Filtering and Frequency
      9. For the More Curious: Retina Display
    12. 9. Notification and Rotation
      1. Notification Center
      2. UIDevice Notifications
      3. Autorotation
        1. Setting autoresizing masks programmatically and bitwise operations
      4. Forcing Landscape Mode
      5. Challenge: Proximity Notifications
      6. For the More Curious: Overriding Autorotation
    13. 10. UITableView and UITableViewController
      1. Beginning the Homepwner Application
      2. UITableViewController
        1. Subclassing UITableViewController
      3. UITableView’s Data Source
        1. PossessionStore: a singleton
        2. Implementing data source methods
      4. UITableViewCells
        1. Creating and retrieving UITableViewCells
        2. Reusing UITableViewCells
      5. Code Snippet Library
      6. Challenge: Sections
    14. 11. Editing UITableView
      1. Editing Mode
      2. Adding Rows
      3. Deleting Rows
      4. Moving Rows
    15. 12. UINavigationController
      1. UINavigationController
        1. UINavigationBar
      2. An Additional UIViewController
      3. Navigating with UINavigationController
        1. Pushing view controllers
        2. Passing data between view controllers
        3. Appearing and disappearing views
      4. Challenge: Number Pad
    16. 13. Camera
      1. Displaying Images and UIImageView
        1. Taking pictures and UIImagePickerController
        2. ImageStore
          1. NSDictionary
        3. Creating and using keys
        4. Dismissing the keyboard
      2. Challenge: Removing an Image
      3. For the More Curious: Recording Video
    17. 14. UIPopoverController and Modal View Controllers
      1. Universalizing Homepwner
      2. UIPopoverController
      3. Modal View Controllers
        1. Dismissing modal view controllers
        2. Modal view controller styles
        3. Writing a view controller delegate protocol
        4. Modal view controller transitions
    18. 15. Saving, Loading, and Multitasking
      1. Application Sandbox
        1. Constructing a file path
      2. Archiving
        1. Archiving objects
        2. Unarchiving objects
      3. Application States, Transitions, and Multitasking
      4. Writing to filesystem with NSData
      5. More on Low-Memory Warnings
      6. Model-View-Controller-Store Design Pattern
      7. Challenge: Archiving Whereami
      8. For The More Curious: Application State Transitions
      9. For the More Curious: Reading and Writing to the filesystem
      10. For the More Curious: The Application Bundle
    19. 16. Subclassing UITableViewCell
      1. Creating HomepwnerItemCell
        1. Creating subviews
        2. Laying out subviews
        3. Using the custom cell
      2. Image Manipulation
      3. Challenge: Accessory Indicators
      4. Challenge: Shrinking the Main Image
    20. 17. Core Data
      1. Object-Relational Mapping
      2. Moving Homepwner to Core Data
        1. The model file
        2. NSManagedObject and subclasses
        3. Updating PossessionStore
        4. Adding AssetTypes to Homepwner
      3. More About SQL
      4. Trade-offs of Persistence Mechanisms
      5. Challenge: New Asset Types
      6. Challenge: Assets on the iPad
    21. 18. Localization
      1. Internationalization using NSLocale
      2. Localizing Resources
      3. NSLocalizedString and Strings Tables
      4. Challenge: Another Localization
      5. For the More Curious: NSBundle’s Role in Internationalization
    22. 19. Settings
      1. Updating Whereami
      2. NSUserDefaults
      3. For the More Curious: The Settings Application
    23. 20. Touch Events and UIResponder
      1. Touch Events
      2. Creating the TouchTracker Application
      3. Turning Touches into Lines
      4. The Responder Chain
      5. Challenge: Saving and Loading
      6. Challenge: Circles
      7. For the More Curious: UIControl
    24. 21. Instruments
      1. The Static Analyzer
      2. Instruments
        1. The Allocations Instrument
          1. Settings in Allocations
          2. Heapshot Analysis
        2. Time Profiler Instrument
      3. Xcode Schemes
        1. Creating a new scheme
      4. Build Settings
    25. 22. Core Animation Layer
      1. Layers and views
      2. Creating a CALayer
      3. Layer Content
      4. Implicitly Animatable Properties
      5. For the More Curious: Programmatically Generating Content
      6. For the More Curious: Layers, Bitmaps, and Contexts
      7. Challenge: Dynamic Layer Content
    26. 23. Controlling Animation with CAAnimation
      1. Animation Objects
      2. Spinning with CABasicAnimation
        1. Timing functions
        2. Animation completion
      3. Bouncing with a CAKeyframeAnimation
      4. Challenge: More Animation
      5. For the More Curious: The Presentation Layer and the Model Layer
    27. 24. Blocks and Categories
      1. Colorizing TouchDrawView
      2. Blocks
        1. Blocks as variables
        2. Capturing variables
        3. Using blocks with other built-in methods
        4. Keeping code compact with blocks
      3. Categories
      4. For the More Curious: Memory Management and Blocks
      5. For the More Curious: Pros and Cons of Callback Options
    28. 25. Web Services and UIWebView
      1. Web Services
        1. Starting the Nerdfeed application
        2. Fetching data from a URL
        3. Working with NSURLConnection
        4. Parsing XML
        5. A quick tip on logging
      2. UIWebView
      3. For the More Curious: NSXMLParser
      4. For the More Curious: The Request Body
      5. For the More Curious: Credentials
      6. Challenge: More Data
      7. Challenge: More UIWebView
    29. 26. UISplitViewController
      1. Splitting Up Nerdfeed
      2. Master-Detail Communication
      3. Displaying the Master View Controller in Portrait Mode
      4. Universalizing Nerdfeed
    30. 27. Media Playback and Background Execution
      1. Creating the MediaPlayer Application
      2. System Sounds
        1. Registering system sounds
        2. Playing system sounds
      3. Compressed Audio Files
      4. Playing Movie Files
        1. MPMoviePlayerViewController
        2. Preloading video
      5. Background Processes
        1. Guidelines for background execution
        2. Other forms of background execution
      6. Low-level APIs
      7. Challenge: Audio Recording
    31. 28. Bonjour and Web Servers
      1. Bonjour
        1. Creating CocoaServer
        2. Publishing a Bonjour service
        3. Browsing for services via Bonjour
      2. HTTP Communication
        1. Writing a web server in Objective-C
        2. Getting address data from the server
        3. Byte ordering
        4. Making service requests
        5. Receiving service requests
      3. For the More Curious: TXTRecords
    32. 29. Push Notifications and Networking
      1. Preparing Client for Push Notifications
        1. Registering for notifications
        2. Provisioning for push notifications
      2. Delivering a Push Notification
        1. Getting the token to the provider
      3. Sending Push Notifications
        1. Connecting to Apple’s server with NSStream
          1. Using NSStream
          2. Providing data to the notification server
          3. Detecting errors in notification delivery
          4. More on reading from a stream
      4. Additional Client-side Notification Handling
        1. Sounds and badges
        2. Accessing data in notifications
      5. The Production Server and Moving Forward
      6. For the More Curious: The Feedback Service
    33. 30. Afterword
      1. What to do next
      2. Shameless plugs
    34. Index
    35. More From Big Nerd Ranch...

    Product information

    • Title: iOS Programming: The Big Nerd Ranch Guide, Second Edition
    • Author(s):
    • Release date: June 2011
    • Publisher(s): Big Nerd Ranch Guides
    • ISBN: 9780132757058