You are previewing Programming iOS 5, 2nd Edition.
O'Reilly logo
Programming iOS 5, 2nd Edition

Book Description

Get a solid grounding in the fundamentals of Cocoa Touch—and avoid problems during iPhone and iPad app development. With this revised and expanded edition, you’ll dig into Cocoa and learn how to work effectively with Objective-C and Xcode. This book covers iOS 5 and Xcode 4.3 in a rigorous, orderly fashion—ideal whether you’re approaching iOS for the first time or need a reference to bolster existing skills.

Table of Contents

  1. Programming iOS 5
  2. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
    5. Acknowledgments for the First Edition
    6. Notes on the Second Printing
    7. Acknowledgments for the Second Edition
    8. Notes on the Second Edition
  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
      6. CFTypeRefs
      7. 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 and Storyboard 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. Making and Loading a Nib
      4. Outlet Connections
        1. More Ways to Create Outlets
        2. More About Outlets
      5. Action Connections
      6. 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 and Fix-it
      4. Navigating Your Code
      5. Debugging
        1. Caveman Debugging
        2. The Xcode Debugger
      6. Unit Testing
      7. Static Analyzer
      8. Clean
      9. Running in the Simulator
      10. Running on a Device
      11. Device Management
      12. Version Control
      13. Instruments
      14. Distribution
      15. Ad Hoc Distribution
      16. Final App Preparations
        1. Icons in the App
        2. Other Icons
        3. Launch Images
        4. Screenshots
        5. Property List Settings
      17. 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. Principles of Cocoa Memory Management
        2. The Golden Rules of Memory Management
        3. What ARC Is and What It Does
        4. How Cocoa Objects Manage Memory
        5. Autorelease
        6. Memory Management of Instance Variables (Non-ARC)
        7. Memory Management of Instance Variables (ARC)
        8. Retain Cycles and Weak References
        9. Nib Loading and Memory Management
        10. Memory Management of Global Variables
        11. Memory Management of Pointer-to-Void Context Info
        12. Memory Management of CFTypeRefs
      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. Graphics Contexts
      3. UIImage Drawing
      4. CGImage Drawing
      5. CIFilter and CIImage
      6. Drawing a UIView
      7. Graphics Context Settings
      8. Paths and Drawing
      9. Clipping
      10. Gradients
      11. Colors and Patterns
      12. Graphics Context Transforms
      13. Shadows
      14. Points and Pixels
      15. 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. Content Resizing and Positioning
        2. Layers that Draw Themselves
      4. Transforms
        1. Depth
      5. Shadows, Borders, and More
      6. Layers and Key–Value Coding
    4. 17. Animation
      1. Drawing, Animation, and Threading
      2. UIImageView and UIImage 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
      7. Emitter Layers
    5. 18. Touches
      1. Touch Events and Views
      2. Receiving Touches
      3. Restricting Touches
      4. Interpreting Touches
      5. Gesture Recognizers
        1. Gesture Recognizer Classes
        2. Multiple Gesture Recognizers
        3. Subclassing Gesture Recognizers
        4. 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. The View Controller Hierarchy
      2. View Controller and View Creation
        1. Manual View
        2. Generic Automatic View
        3. View in a Separate Nib
        4. Nib-Instantiated View Controller
        5. Storyboard-Instantiated View Controller
      3. Rotation
        1. Rotation Events
        2. Initial Orientation
      4. Presented View Controller
        1. Presented View Animation
        2. Presentation Styles
        3. Presented Views and Rotation
      5. Tab Bar Controllers
        1. Tab Bar Items
        2. Configuring a Tab Bar Controller
      6. Navigation Controllers
        1. Bar Button Items
        2. Navigation Items
        3. Toolbar Items
        4. Configuring a Navigation Controller
      7. Page View Controller
      8. Container View Controllers
      9. Storyboards
      10. View Controller Lifetime Events
      11. 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
          4. Designing a cell in a storyboard
      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
        5. Dynamic Table Content
      7. Table View Menus
    4. 22. Popovers and Split Views
      1. Configuring and Displaying a Popover
      2. Managing a Popover
      3. Dismissing a Popover
      4. Popover Segues
      5. Automatic Popovers
      6. Split Views
    5. 23. Text
      1. UILabel
      2. UITextField
        1. Editing and the Keyboard
          1. Dismissing the keyboard
          2. Keyboard covers text field
        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. UIStepper
        3. UIPageControl
        4. UIDatePicker
        5. UISlider
        6. UISegmentedControl
        7. UIButton
        8. Custom Controls
      6. Bars
        1. UINavigationBar
        2. UIToolbar
        3. UITabBar
      7. Appearance Proxy
    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
        1. Interruptions
        2. Routing Changes
      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. An Introduction to AV Foundation Video
    3. 29. Music Library
      1. Exploring the Music Library
      2. The Music Player
      3. The Music Picker
    4. 30. Photo Library and Image Capture
      1. UIImagePickerController
        1. Choosing from the Photo Library
        2. Using the Camera
      2. Image Capture With AV Foundation
      3. 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. Displaying a Map
      2. Annotations
      3. Overlays
    9. 35. Sensors
      1. Location
        1. Map Kit and Core Location
        2. Geocoding
        3. Location Manager
      2. Heading
      3. Acceleration and Attitude
        1. Shake Events
        2. Raw Acceleration
        3. Gyroscope
  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. The Document Architecture
      9. XML
      10. SQLite
      11. 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
  13. Copyright