More iPhone 3 Development: Tackling iPhone SDK 3

Book description

Whether you're a self-taught iPhone development genius or have just made your way through the pages of Beginning iPhone 3 Development, we have the perfect book for you.

Table of contents

  1. Copyright
  2. About the Authors
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Preface
  6. 1. Here We Go Round Again
    1. 1.1. What This Book Is
    2. 1.2. What You Need to Know
    3. 1.3. What You Need Before You Can Begin
    4. 1.4. What's In this Book
    5. 1.5. Are You Ready?
  7. I. Core Data
    1. 2. The Anatomy of Core Data
      1. 2.1. A Brief History of Core Data
      2. 2.2. Creating a Core Data Template Application
      3. 2.3. Core Data Concepts and Terminology
      4. 2.4. The Data Model and Persistent Store
        1. 2.4.1. The Data Model Class: NSManagedObjectModel
        2. 2.4.2. The Persistent Store and the Persistent Store Coordinator
        3. 2.4.3. Reviewing the Data Model
      5. 2.5. Entities and the Data Model Editor
        1. 2.5.1. Entities
        2. 2.5.2. Properties
          1. 2.5.2.1. Attributes
          2. 2.5.2.2. Relationships
          3. 2.5.2.3. Fetched Properties
          4. 2.5.2.4. Fetch Requests
      6. 2.6. Managed Objects
        1. 2.6.1. Key-Value Coding
        2. 2.6.2. Managed Object Context
        3. 2.6.3. Saves on Terminate
      7. 2.7. Loading Data from the Persistent Store
      8. 2.8. The Fetched Results Controller
        1. 2.8.1. Creating a Fetched Results Controller
        2. 2.8.2. The Fetched Results Controller Delegate Methods
          1. 2.8.2.1. Will Change Content Delegate Method
          2. 2.8.2.2. Did Change Content Delegate Method
          3. 2.8.2.3. Did Change Object Delegate Method
          4. 2.8.2.4. Did Change Section Delegate Method
        3. 2.8.3. Retrieving a Managed Object from the Fetched Results Controller
        4. 2.8.4. Creating and Inserting a New Managed Object
        5. 2.8.5. Deleting Managed Objects
      9. 2.9. Putting Everything in Context
    2. 3. A Super Start: Adding, Displaying, and Deleting Data
      1. 3.1. Setting up the Xcode Project
        1. 3.1.1. Application Architecture
        2. 3.1.2. Modifying the Application Delegate Interface
        3. 3.1.3. Adding to the Application Delegate Implementation
      2. 3.2. Creating the Table View Controller
      3. 3.3. Setting up MainWindow.xib
        1. 3.3.1. Connecting the Outlets
      4. 3.4. Designing the Data Model
        1. 3.4.1. Adding an Entity
        2. 3.4.2. Editing the New Entity
        3. 3.4.3. Adding Attributes to the New Entity
        4. 3.4.4. Adding the Name Attribute
        5. 3.4.5. Editing the Attribute
          1. 3.4.5.1. Attribute Types
          2. 3.4.5.2. The Integer Datatypes
            1. 3.4.5.2.1. The Decimal, Double, and Float Datatypes
            2. 3.4.5.2.2. The String Datatype
            3. 3.4.5.2.3. The Boolean Datatype
            4. 3.4.5.2.4. The Date Datatype
            5. 3.4.5.2.5. The Binary Datatype
            6. 3.4.5.2.6. The Transformable Datatype
          3. 3.4.5.3. Setting the Name Attributes's Type
          4. 3.4.5.4. Adding the Rest of the Attributes
      5. 3.5. Creating HeroListViewController
        1. 3.5.1. Declaring the Fetched Results Controller
        2. 3.5.2. Drag Two Icons to Your Project
        3. 3.5.3. Designing the HeroListViewController Interface
        4. 3.5.4. Implementing the Hero View Controller
      6. 3.6. Let 'Er Rip
      7. 3.7. Done, but Not Done
    3. 4. The Devil in the Detail View
      1. 4.1. Table-Based vs. Nib-Based Detail Views
      2. 4.2. Detail Editing View Challenges
      3. 4.3. Controlling Table Structure with Arrays
      4. 4.4. Paired Arrays
        1. 4.4.1. Nested Arrays
        2. 4.4.2. Paired Nested Arrays
        3. 4.4.3. Representing Our Table Structure with Arrays
        4. 4.4.4. Nested Arrays, Categorically Speaking
        5. 4.4.5. Updating the SuperDB Project
      5. 4.5. Formatting of Attributes
      6. 4.6. Creating the Detail View Controller
        1. 4.6.1. Declaring Instance Variables and Properties
        2. 4.6.2. Implementing the Viewing Functionality
        3. 4.6.3. Using the New Controller
          1. 4.6.3.1. Declaring the Outlet
          2. 4.6.3.2. Adding the Instance to MainWindow.xib
          3. 4.6.3.3. Pushing the New Instance onto the Stack
        4. 4.6.4. Trying Out the View Functionality
      7. 4.7. Adding Editing Subcontrollers
        1. 4.7.1. Creating the Superclass
        2. 4.7.2. Creating the String Attribute Editor
        3. 4.7.3. Creating the Date Attribute Editor
        4. 4.7.4. Using the Attribute Editors
      8. 4.8. Implementing a Selection List
        1. 4.8.1. Creating the Generic Selection List Controller
      9. 4.9. Devil's End
    4. 5. Preparing for Change: Migrations and Versioning
      1. 5.1. About Data Models
        1. 5.1.1. Data Models Are Compiled
        2. 5.1.2. Data Models Can Have Multiple Versions
          1. 5.1.2.1. Creating a New Data Model Version
          2. 5.1.2.2. The Current Data Model Version
        3. 5.1.3. Data Model Version Identifiers
        4. 5.1.4. Using the Versioned Data Model
      2. 5.2. Migrations
        1. 5.2.1. Lightweight vs. Standard
        2. 5.2.2. Standard Migrations
        3. 5.2.3. Setting up Your App to Use Lightweight Migrations
      3. 5.3. Time to Migrate On
    5. 6. Custom Managed Objects
      1. 6.1. Updating the Data Model
        1. 6.1.1. Adding the Age Attribute
        2. 6.1.2. Adding the Favorite Color Attribute
        3. 6.1.3. Adding a Minimum Length to the Name Attribute
      2. 6.2. Creating the Hero Class
      3. 6.3. Tweaking the Hero Header
      4. 6.4. Defaulting
      5. 6.5. Validation
        1. 6.5.1. Single-Attribute Validations
        2. 6.5.2. Multiple-Attribute Validations
      6. 6.6. Virtual Accessors
      7. 6.7. Adding Validation Feedback
        1. 6.7.1. Updating the ManagedObjectAttributeEditor Header File
        2. 6.7.2. Updating the ManagedObjectAttributeEditor Implementation File
        3. 6.7.3. Updating the Subclasses to Use Validation
          1. 6.7.3.1. Updating ManagedObjectStringEditor
          2. 6.7.3.2. Updating ManagedObjectDateEditor
          3. 6.7.3.3. Updating ManagedObjectSingleSelectionListEditor
      8. 6.8. Creating the Value Transformer
      9. 6.9. Creating the Color Attribute Editor
      10. 6.10. Displaying the New Attributes in Hero Edit Controller
      11. 6.11. The Display Problem
      12. 6.12. Adding View-Only Support to Hero Edit Controller
        1. 6.12.1. Hiding the Disclosure Indicator
        2. 6.12.2. Handling Taps on Read-Only Attributes
      13. 6.13. Color Us Gone
    6. 7. Relationships, Fetched Properties, and Expressions
      1. 7.1. Expanding Our Application: Superpowers and Reports
      2. 7.2. Relationships
        1. 7.2.1. To-One Relationships
        2. 7.2.2. To-Many Relationships
        3. 7.2.3. Inverse Relationships
        4. 7.2.4. Delete Rules
      3. 7.3. Fetched Properties
      4. 7.4. Creating Relationships and Fetched Properties in the Data Model Editor
        1. 7.4.1. Adding the Power Entity
        2. 7.4.2. Creating the Powers Relationship
        3. 7.4.3. Creating the Inverse Relationship
        4. 7.4.4. Creating the olderHeroes Fetched Property
        5. 7.4.5. Creating the youngerHeroes Fetched Property
        6. 7.4.6. Creating the sameSexHeroes Fetched Property
        7. 7.4.7. Creating the oppositeSexHeroes Fetched Property
      5. 7.5. Adding Relationships and Fetched Properties to the Hero Class
      6. 7.6. The Big Refactor
        1. 7.6.1. Renaming the Class
        2. 7.6.2. Refactoring the hero Instance Variable
        3. 7.6.3. Removing the Arrays
        4. 7.6.4. Supporting Save and Cancel Buttons
          1. 7.6.4.1. Adding the isNew Method to NSManagedObject
          2. 7.6.4.2. Adding the Save and Cancel Buttons
        5. 7.6.5. Adding Support for To-Many Relationships
          1. 7.6.5.1. Turning on Edit Mode
          2. 7.6.5.2. Setting Row Indentation
          3. 7.6.5.3. Setting the Correct Number of Rows for To-Many Sections
          4. 7.6.5.4. The Set Problem
          5. 7.6.5.5. Specifying the Editing Style for the Rows
          6. 7.6.5.6. Displaying To-Many Sections
          7. 7.6.5.7. Updating Row Selection for To-Many Relationships
          8. 7.6.5.8. Handling To-Many Inserts and Deletes
      7. 7.7. Using the New Generic Controller
        1. 7.7.1. Adding Factory Methods for Hero and Power
        2. 7.7.2. Deleting the Nib Instance
        3. 7.7.3. Updating HeroListController
      8. 7.8. Creating the Fetched Property Attribute Controller
      9. 7.9. Cleaning Up Deleted Objects
      10. 7.10. Wonderful to the Core
  8. II. Further Explorations
    1. 8. Peer-to-Peer Over Bluetooth Using GameKit
      1. 8.1. This Chapter's Application
      2. 8.2. Network Communication Models
        1. 8.2.1. Client-Server Model
        2. 8.2.2. Peer-to-Peer Model
        3. 8.2.3. Hybrid Client-Server/Peer-to-Peer
      3. 8.3. The GameKit Session
        1. 8.3.1. Creating the Session
        2. 8.3.2. Finding and Connecting to Other Sessions
        3. 8.3.3. Listening for Other Sessions
        4. 8.3.4. Sending Data to a Peer
        5. 8.3.5. Packaging Up Information to Send
        6. 8.3.6. Receiving Data from a Peer
        7. 8.3.7. Closing Connections
      4. 8.4. The Peer Picker
        1. 8.4.1. Creating the Peer Picker
        2. 8.4.2. Handling a Peer Connection
        3. 8.4.3. Creating the Session
      5. 8.5. Creating the Project
        1. 8.5.1. Turning Off the Idle Timer
        2. 8.5.2. Importing the GameKit Framework
        3. 8.5.3. Designing the Interface
          1. 8.5.3.1. Setting Up the View Controller Header
          2. 8.5.3.2. Designing the Game Board
          3. 8.5.3.3. Creating the TicTacToePacket Object
          4. 8.5.3.4. Implementing the Tic-Tac-Toe View Controller
      6. 8.6. Trying It Out
      7. 8.7. Game On!
    2. 9. Online Play: Bonjour and Network Streams
      1. 9.1. This Chapter's Application
      2. 9.2. Overview of the Process
      3. 9.3. Setting Up a Listener
        1. 9.3.1. Callback Functions and Run Loop Integration
        2. 9.3.2. Configuring a Socket
          1. 9.3.2.1. Declaring a Socket Context
          2. 9.3.2.2. Creating a Socket
        3. 9.3.3. Specifying a Port for Listening
        4. 9.3.4. Registering the Socket with the Run Loop
        5. 9.3.5. Implementing the Socket Callback Function
        6. 9.3.6. Stopping the Listener
      4. 9.4. Bonjour
        1. 9.4.1. Creating a Service for Publication
          1. 9.4.1.1. Publishing a Bonjour Service
          2. 9.4.1.2. Stopping a Bonjour Service
          3. 9.4.1.3. Delegate Methods for Publication
        2. 9.4.2. Searching for Published Bonjour Services
        3. 9.4.3. Browser Delegate Methods
        4. 9.4.4. Resolving a Discovered Service
      5. 9.5. Streams
        1. 9.5.1. Opening a Stream
        2. 9.5.2. The Stream and Its Delegate
        3. 9.5.3. Receiving Data from a Stream
        4. 9.5.4. Sending Data Through the Stream
      6. 9.6. Putting It All Together
      7. 9.7. Updating Tic-Tac-Toe for Online Play
        1. 9.7.1. Adding the Packet Categories
        2. 9.7.2. Implementing the Online Session Object
        3. 9.7.3. Creating the Listener Object
        4. 9.7.4. Creating the Peer Browser
          1. 9.7.4.1. Creating the Peer Browser Files
          2. 9.7.4.2. Writing the Peer Browser Header
          3. 9.7.4.3. Building the Peer Browser Interface
          4. 9.7.4.4. Implementing the Peer Browser View Controller
        5. 9.7.5. Updating TicTacToeViewController to Support Online Play
      8. 9.8. Time to Play
    3. 10. Working with Data from the Web
      1. 10.1. Setting Up the Application Skeleton
        1. 10.1.1. Declaring Actions and Outlets
        2. 10.1.2. Designing the Interface
        3. 10.1.3. Implementing the Stubs
      2. 10.2. Retrieving Data Using Foundation Objects
      3. 10.3. Retrieving Data Synchronously
        1. 10.3.1. The URL Request
      4. 10.4. Retrieving Data Asynchronously
        1. 10.4.1. NSURLConnection Delegate Methods
        2. 10.4.2. Adding Asynchronous Retrieval to WebWorks
      5. 10.5. Request Types and Form Parameters
        1. 10.5.1. Specifying the HTTP Request Types
        2. 10.5.2. Form Parameters
          1. 10.5.2.1. GET Parameters
          2. 10.5.2.2. POST Parameters
        3. 10.5.3. Building the RequestTypes Application
      6. 10.6. 404 Conclusion Not Found
    4. 11. MapKit
      1. 11.1. This Chapter's Application
      2. 11.2. Overview and Terminology
      3. 11.3. The Map View
        1. 11.3.1. Map Types
        2. 11.3.2. User Location
        3. 11.3.3. Coordinate Regions
          1. 11.3.3.1. Converting Degrees to Distance
          2. 11.3.3.2. Accommodating Aspect Ratio
        4. 11.3.4. Setting the Region to Display
        5. 11.3.5. The Map View Delegate
          1. 11.3.5.1. Map Loading Delegate Methods
          2. 11.3.5.2. Region Change Delegate Methods
      4. 11.4. Annotations
        1. 11.4.1. The Annotation Object
        2. 11.4.2. The Annotation View
        3. 11.4.3. Adding and Removing Annotations
        4. 11.4.4. Selecting Annotations
        5. 11.4.5. Providing the Map View with Annotation Views
      5. 11.5. Reverse Geocoding
      6. 11.6. Building the MapMe Application
        1. 11.6.1. Declaring Outlets and Actions
        2. 11.6.2. Building the Interface
        3. 11.6.3. Writing the Annotation Object Class
        4. 11.6.4. Implementing MapMeViewController
        5. 11.6.5. Linking the Map Kit and Core Location Frameworks
      7. 11.7. Go East, Young Programmer
    5. 12. Sending Mail
      1. 12.1. This Chapter's Application
      2. 12.2. The MessageUI Framework
        1. 12.2.1. Creating the Mail Compose View Controller
        2. 12.2.2. Prepopulating the Subject Line
        3. 12.2.3. Prepopulating Recipients
        4. 12.2.4. Setting the Message Body
        5. 12.2.5. Adding Attachments
        6. 12.2.6. Presenting the Mail Compose View
        7. 12.2.7. The Mail Compose View Controller Delegate Method
      3. 12.3. Building the MailPic Application
        1. 12.3.1. Declaring Outlets and Actions
        2. 12.3.2. Building the User Interface
        3. 12.3.3. Implementing the View Controller
        4. 12.3.4. Linking the MessageUI Framework
      4. 12.4. Mailing It In...
    6. 13. iPod Library Access
      1. 13.1. This Chapter's Application
      2. 13.2. Working with the iPod Library
        1. 13.2.1. Media Items
          1. 13.2.1.1. Media Item Persistent ID
          2. 13.2.1.2. Media Type
          3. 13.2.1.3. Filterable String Properties
          4. 13.2.1.4. Nonfilterable Numeric Attributes
          5. 13.2.1.5. Retrieving Lyrics
          6. 13.2.1.6. Retrieving Album Artwork
          7. 13.2.1.7. Retrieving the Date Last Played
        2. 13.2.2. Media Item Collections
          1. 13.2.2.1. Creating a New Collection
          2. 13.2.2.2. Retrieving Media Items
          3. 13.2.2.3. Creating Derived Collections
        3. 13.2.3. Media Queries and Media Property Predicates
        4. 13.2.4. The Media Picker Controller
          1. 13.2.4.1. Handling Media Picker Cancels
          2. 13.2.4.2. Handling Media Picker Selections
        5. 13.2.5. The Music Player Controller
          1. 13.2.5.1. Creating the Music Player Controller
          2. 13.2.5.2. Determining If the Music Player Controller Is Playing
          3. 13.2.5.3. Specifying the Music Player Controller's Queue
          4. 13.2.5.4. Getting or Setting the Currently Playing Media Item
          5. 13.2.5.5. Skipping Tracks
          6. 13.2.5.6. Seeking
          7. 13.2.5.7. Playback Time
          8. 13.2.5.8. Repeat and Shuffle Modes
          9. 13.2.5.9. Adjusting the Music Player Controller's Volume
          10. 13.2.5.10. Music Player Controller Notifications
      3. 13.3. Building the Simple Player Application
        1. 13.3.1. Adding Media Item Collection Functionality
        2. 13.3.2. Declaring Outlets and Actions
        3. 13.3.3. Building the User Interface
        4. 13.3.4. Implementing the Simple Player View Controller
        5. 13.3.5. Taking Simple Player for a Spin
      4. 13.4. Avast! Rough Waters Ahead!
    7. 14. Keeping Your Interface Responsive
      1. 14.1. Exploring the Concurrency Problem
      2. 14.2. Creating the Stalled Application
        1. 14.2.1. Declaring Actions and Outlets
        2. 14.2.2. Designing the Interface
        3. 14.2.3. Implementing the Stalled View Controller
      3. 14.3. Timers
        1. 14.3.1. Creating a Timer
        2. 14.3.2. Stopping a Timer
        3. 14.3.3. Limitations of Timers
      4. 14.4. Fixing Stalled with a Timer
        1. 14.4.1. Creating the Batch Object
        2. 14.4.2. Updating the Controller Header
        3. 14.4.3. Updating the Nib
        4. 14.4.4. Updating the View Controller Implementation
      5. 14.5. Operation Queues & Concurrency
        1. 14.5.1. Threads
          1. 14.5.1.1. Race Conditions
          2. 14.5.1.2. Mutex Locks and @synchronized
          3. 14.5.1.3. Atomicity and Thread Safety
          4. 14.5.1.4. Deadlocks
          5. 14.5.1.5. Sleepy Time
        2. 14.5.2. Operations
          1. 14.5.2.1. Operation Dependencies
          2. 14.5.2.2. Operation Priority
          3. 14.5.2.3. Other Operation State
          4. 14.5.2.4. Cancelling an Operation
        3. 14.5.3. Operation Queues
          1. 14.5.3.1. Adding Operations to the Queue
          2. 14.5.3.2. Setting the Maximum Concurrent Operation Count
          3. 14.5.3.3. Suspending the Queue
      6. 14.6. Fixing Stalled with an Operation Queue
        1. 14.6.1. Creating SquareRootApplication
        2. 14.6.2. Changes to StalledViewController.h
        3. 14.6.3. Adjusting the User Interface
      7. 14.7. Updating StalledViewController.m
      8. 14.8. Queue 'em Up
    8. 15. Debugging
      1. 15.1. The Debugger
        1. 15.1.1. Breakpoints
          1. 15.1.1.1. The Debugger Editing Pane
          2. 15.1.1.2. The Stack Trace
          3. 15.1.1.3. The Variable List
          4. 15.1.1.4. The Debugging Controls
          5. 15.1.1.5. Trying Out the Debug Controls
          6. 15.1.1.6. The Breakpoint Window and Symbolic Breakpoints
          7. 15.1.1.7. Conditional Breakpoints
          8. 15.1.1.8. Breakpoint Actions
        2. 15.1.2. The GDB Console
          1. 15.1.2.1. The Info Command
          2. 15.1.2.2. Working with Breakpoints
            1. 15.1.2.2.1. Creating Breakpoints
            2. 15.1.2.2.2. Removing Breakpoints
          3. 15.1.2.3. Printing Data and Object Values
          4. 15.1.2.4. Calling Functions and Methods
      2. 15.2. Static Analysis
      3. 15.3. Specific Bugs
        1. 15.3.1. Overreleasing Memory
          1. 15.3.1.1. NSZombie
        2. 15.3.2. Infinite Recursion
        3. 15.3.3. Missed Outlet and Action Connections
      4. 15.4. GDB: Stopped at Concluding Paragraph
    9. 16. The Road Goes Ever On...
      1. 16.1. Getting Unstuck
        1. 16.1.1. Apple's Documentation
        2. 16.1.2. Mailing Lists
        3. 16.1.3. Discussion Forums
        4. 16.1.4. Web Sites
        5. 16.1.5. Blogs
        6. 16.1.6. And If All Else Fails...
      2. 16.2. Farewell

Product information

  • Title: More iPhone 3 Development: Tackling iPhone SDK 3
  • Author(s):
  • Release date: January 2010
  • Publisher(s): Apress
  • ISBN: 9781430225058