You are previewing Programming iOS 4.
O'Reilly logo
Programming iOS 4

Book Description

Whether you're learning Cocoa programming for the first time, or want a reference to bolster the iPhone development skills you already have, this in-depth guide provides a complete learning path -- from language basics and using Xcode and Interface Builder to all of the steps necessary for developing your app with the Cocoa framework. You'll learn everything you need to take an iPhone, iPad, or iPod touch app from initial concept to the App Store.

Table of Contents

  1. Programming iOS 4
    1. A Note Regarding Supplemental Files
    2. Preface
      1. Conventions Used in This Book
      2. Using Code Examples
      3. Safari® Books Online
      4. How to Contact Us
      5. Acknowledgments
      6. Notes on the Second Printing
    3. I. Language
      1. 1. Just Enough C
        1. Compilation, Statements, and Comments
        2. Variable Declaration, Initialization, and Data Types
        3. Structs
        4. Pointers
        5. Arrays
        6. Operators
        7. Flow Control and Conditions
        8. Functions
        9. Pointer Parameters and the Address Operator
        10. Files
        11. The Standard Library
        12. More Preprocessor Directives
        13. Data Type Qualifiers
      2. 2. Object-Based Programming
        1. Objects
        2. Messages and Methods
        3. Classes and Instances
        4. Class Methods
        5. Instance Variables
        6. The Object-Based Philosophy
      3. 3. Objective-C Objects and Messages
        1. An Instance Reference Is a Pointer
          1. Instance References, Initialization, and nil
          2. Instance References and Assignment
          3. Instance References and Memory Management
        2. Messages and Methods
          1. Sending a Message
          2. Declaring a Method
          3. Nesting Method Calls
          4. No Overloading
          5. Parameter Lists
          6. Unrecognized Selectors
        3. Typecasting and the id Type
        4. Messages as Data Type
        5. C Functions and Struct Pointers
        6. Blocks
      4. 4. Objective-C Classes
        1. Class and Superclass
        2. Interface and Implementation
        3. Header File and Implementation File
        4. Class Methods
        5. The Secret Life of Classes
      5. 5. Objective-C Instances
        1. How Instances Are Created
          1. Ready-Made Instances
          2. Instantiation from Scratch
            1. Initialization
            2. The designated initializer
          3. Nib-Based Instantiation
        2. Polymorphism
        3. The Keyword self
        4. The Keyword super
        5. Instance Variables and Accessors
        6. Key–Value Coding
        7. Properties
        8. How to Write an Initializer
    4. II. IDE
      1. 6. Anatomy of an Xcode Project
        1. New Project
        2. The Project Window
          1. The Navigator Pane
          2. The Utilities Pane
          3. The Editor
        3. The Project File and Its Dependents
        4. The Target
          1. Build Phases
          2. Build Settings
          3. Configurations
          4. Schemes and Destinations
        5. From Project to App
          1. Build Settings
          2. Property List Settings
          3. Nib Files
          4. Other Resources
          5. Code
          6. Frameworks and SDKs
      2. 7. Nib Management
        1. A Tour of the Nib-Editing Interface
          1. The Dock
          2. Canvas
          3. Inspectors and Libraries
        2. Nib Loading and File’s Owner
        3. Default Instances in the Main Nib File
        4. Making and Loading a Nib
        5. Outlet Connections
          1. More Ways to Create Outlets
          2. More About Outlets
        6. Action Connections
        7. Additional Initialization of Nib-Based Instances
      3. 8. Documentation
        1. The Documentation Window
        2. Class Documentation Pages
        3. Sample Code
        4. Other Resources
          1. Quick Help
          2. Symbols
          3. Header Files
          4. Internet Resources
      4. 9. Life Cycle of a Project
        1. Choosing a Device Architecture
        2. Localization
        3. Editing Your Code
          1. Autocompletion
          2. Snippets
          3. Live Syntax Checking
        4. Navigating Your Code
        5. Debugging
          1. Caveman Debugging
          2. The Xcode Debugger
        6. Static Analyzer
        7. Clean
        8. Running in the Simulator
        9. Running on a Device
        10. Device Management
        11. Version Control
        12. Instruments
        13. Distribution
        14. Ad Hoc Distribution
        15. Final App Preparations
          1. Icons in the App
          2. Other Icons
          3. Launch Images
          4. Screenshots
          5. Property List Settings
        16. Submission to the App Store
    5. III. Cocoa
      1. 10. Cocoa Classes
        1. Subclassing
        2. Categories
          1. Splitting a Class
          2. Private Method Declarations
        3. Protocols
        4. Optional Methods
        5. Some Foundation Classes
          1. Useful Structs and Constants
          2. NSString and Friends
          3. NSDate and Friends
          4. NSNumber
          5. NSValue
          6. NSData
          7. Equality and Comparison
          8. NSIndexSet
          9. NSArray and NSMutableArray
          10. NSSet and Friends
          11. NSDictionary and NSMutableDictionary
          12. NSNull
          13. Immutable and Mutable
          14. Property Lists
        6. The Secret Life of NSObject
      2. 11. Cocoa Events
        1. Reasons for Events
        2. Subclassing
        3. Notifications
          1. Receiving a Built-In Notification
          2. Unregistering
          3. NSTimer
        4. Delegation
        5. Data Sources
        6. Actions
        7. The Responder Chain
          1. Deferring Responsibility
          2. Nil-Targeted Actions
        8. Application Lifetime Events
        9. Swamped by Events
      3. 12. Accessors and Memory Management
        1. Accessors
        2. Key–Value Coding
        3. Memory Management
          1. The Golden Rules of Memory Management
          2. How Cocoa Objects Manage Memory
          3. Memory Management of Instance Variables
          4. Instance Variable Memory Management Policies
          5. Autorelease
          6. Nib Loading and Memory Management
          7. Memory Management Comments on Earlier Examples
          8. Memory Management of Pointer-to-Void Context Info
          9. Memory Management of C Struct Pointers
        4. Properties
      4. 13. Data Communication
        1. Model–View–Controller
        2. Instance Visibility
          1. Visibility by Instantiation
          2. Visibility by Relationship
          3. Global Visibility
        3. Notifications
        4. Key–Value Observing
    6. IV. Views
      1. 14. Views
        1. The Window
        2. Subview and Superview
        3. Frame
        4. Bounds and Center
        5. Layout
        6. Transform
        7. Visibility and Opacity
      2. 15. Drawing
        1. UIImage and UIImageView
        2. UIImage and Graphics Contexts
        3. CGImage
        4. Drawing a UIView
        5. Graphics Context State
        6. Paths
        7. Clipping
        8. Gradients
        9. Colors and Patterns
        10. Graphics Context Transforms
        11. Shadows
        12. Points and Pixels
        13. Content Mode
      3. 16. Layers
        1. View and Layer
        2. Layers and Sublayers
          1. Manipulating the Layer Hierarchy
          2. Positioning a Sublayer
          3. CAScrollLayer
          4. Layout of Sublayers
        3. Drawing in a Layer
          1. Contents Image
          2. Contents on Demand
          3. Contents Resizing and Positioning
          4. Layers that Draw Themselves
        4. Transforms
          1. Depth
          2. Transforms and Key–Value Coding
        5. Shadows, Borders, and More
        6. Layers and Key–Value Coding
      4. 17. Animation
        1. Drawing, Animation, and Threading
        2. UIImageView Animation
        3. View Animation
          1. Animation Blocks
          2. Modifying an Animation Block
          3. Transition Animations
          4. Block-Based View Animation
        4. Implicit Layer Animation
          1. Animation Transactions
          2. Media Timing Functions
        5. Core Animation
          1. CABasicAnimation and Its Inheritance
          2. Using a CABasicAnimation
          3. Keyframe Animation
          4. Making a Property Animatable
          5. Grouped Animations
          6. Transitions
          7. The Animations List
        6. Actions
          1. What an Action Is
          2. The Action Search
          3. Hooking Into the Action Search
          4. Nonproperty Actions
      5. 18. Touches
        1. Touch Events and Views
        2. Receiving Touches
        3. Restricting Touches
        4. Interpreting Touches
        5. Gesture Recognizers
          1. Distinguishing Gestures Manually
          2. Gesture Recognizer Classes
          3. Multiple Gesture Recognizers
          4. Subclassing Gesture Recognizers
          5. Gesture Recognizer Delegate
        6. Touch Delivery
          1. Hit-Testing
            1. Hit-testing for layers
            2. Hit-testing for drawings
            3. Hit-testing during animation
          2. Initial Touch Event Delivery
          3. Gesture Recognizer and View
          4. Touch Exclusion Logic
          5. Recognition
          6. Touches and the Responder Chain
    7. V. Interface
      1. 19. View Controllers
        1. Creating a View Controller
          1. Manual View Controller, Manual View
          2. Manual View Controller, Nib View
          3. Nib-Instantiated View Controller
          4. No View
          5. Up-Shifted Root View
        2. Rotation
          1. Initial Orientation
          2. Rotation Events
        3. Modal Views
          1. Modal View Configuration
          2. Modal View Presentation
          3. Modal View Dismissal
          4. Modal Views and Rotation
        4. Tab Bar Controllers
          1. Tab Bar Item Images
          2. Configuring a Tab Bar Controller
        5. Navigation Controllers
          1. Bar Button Items
          2. Configuring a Navigation Interface
            1. View controller’s navigation item
            2. View controller’s toolbar items
            3. Configuring the navigation view controller
          3. Navigation Interface Rotation
        6. View Controller Lifetime Events
        7. View Controller Memory Management
      2. 20. Scroll Views
        1. Creating a Scroll View
        2. Scrolling
          1. Paging
          2. Tiling
        3. Zooming
          1. Zooming Programmatically
          2. Zooming with Detail
        4. Scroll View Delegate
        5. Scroll View Touches
        6. Scroll View Performance
      3. 21. Table Views
        1. Table View Cells
          1. Built-In Cell Styles
          2. Custom Cells
            1. Overriding a cell’s subview layout
            2. Adding subviews in code
            3. Designing a cell in a nib
        2. Table View Data
          1. The Three Big Questions
          2. Table View Sections
          3. Refreshing Table View Data
          4. Variable Row Heights
        3. Table View Selection
        4. Table View Scrolling and Layout
        5. Table View Searching
        6. Table View Editing
          1. Deleting Table Items
          2. Editable Content in Table Items
          3. Inserting Table Items
          4. Rearranging Table Items
      4. 22. Popovers and Split Views
        1. Presenting a Popover
        2. Managing a Popover
        3. Dismissing a Popover
        4. Automatic Popovers
        5. Split Views
      5. 23. Text
        1. UILabel
        2. UITextField
          1. Editing and the Keyboard
          2. Configuring the Keyboard
          3. Text Field Delegate and Control Event Messages
          4. The Text Field Menu
        3. UITextView
        4. Core Text
      6. 24. Web Views
        1. Loading Content
        2. Communicating with a Web View
      7. 25. Controls and Other Views
        1. UIActivityIndicatorView
        2. UIProgressView
        3. UIPickerView
        4. UISearchBar
        5. UIControl
          1. UISwitch
          2. UIPageControl
          3. UIDatePicker
          4. UISlider
          5. UISegmentedControl
          6. UIButton
          7. Custom Controls
        6. Bars
          1. UINavigationBar
          2. UIToolbar
          3. UITabBar
      8. 26. Modal Dialogs
        1. Alert View
        2. Action Sheet
        3. Dialog Alternatives
        4. Local Notifications
    8. VI. Some Frameworks
      1. 27. Audio
        1. System Sounds
        2. Audio Session
        3. Audio Player
        4. Remote Control of Your Sound
        5. Playing Sound in the Background
        6. Further Topics in Sound
      2. 28. Video
        1. MPMoviePlayerController
        2. MPMoviePlayerViewController
        3. UIVideoEditorController
        4. Further Topics in Video
      3. 29. Music Library
        1. Exploring the Music Library
        2. The Music Player
        3. The Music Picker
      4. 30. Photo Library
        1. UIImagePickerController
          1. Choosing from the Photo Library
          2. Using the Camera
        2. The Assets Library Framework
      5. 31. Address Book
        1. Address Book Database
        2. Address Book Interface
          1. ABPeoplePickerNavigationController
          2. ABPersonViewController
          3. ABNewPersonViewController
          4. ABUnknownPersonViewController
      6. 32. Calendar
        1. Calendar Database
        2. Calendar Interface
      7. 33. Mail
        1. Mail Message
        2. SMS Message
      8. 34. Maps
        1. Presenting a Map
        2. Annotations
        3. Overlays
      9. 35. Sensors
        1. Location
        2. Heading and Course
        3. Acceleration
          1. Shake Events
          2. UIAccelerometer
          3. Core Motion
    9. VII. Final Topics
      1. 36. Persistent Storage
        1. The Sandbox
        2. Basic File Operations
        3. Saving and Reading Files
        4. User Defaults
        5. File Sharing
        6. Document Types
        7. Handing Off a Document
        8. XML
        9. SQLite
        10. Image File Formats
      2. 37. Basic Networking
        1. HTTP Requests
        2. Bonjour
        3. Push Notifications
        4. Beyond Basic Networking
      3. 38. Threads
        1. The Main Thread
        2. Why Threading Is Hard
        3. Three Ways of Threading
          1. Manual Threads
          2. NSOperation
          3. Grand Central Dispatch
        4. Threads and App Backgrounding
      4. 39. Undo
        1. The Undo Manager
        2. The Undo Interface
        3. The Undo Architecture
      5. 40. Epilogue
    10. Index
    11. About the Author
    12. Colophon