Preface xiii 1 Device-Specific Development 1 Accessing Basic Device Information 1 Adding Device Capability Restrictions 2 Recipe: Checking Device Proximity and Battery States 5 Recipe: Recovering Additional Device Information 9 Recipe: Using Acceleration to Locate "Up" 11 Working with Basic Orientation 12 Retrieving the Current Accelerometer Angle Synchronously 13 Recipe: Using Acceleration to Move Onscreen Objects 16 Recipe: Accelerometer-Based Scroll View 19 Recipe: Core Motion Basics 21 Recipe: Retrieving and Using Device Attitude 26 Detecting Shakes Using Motion Events 27 Recipe: Using External Screens 29 Tracking Users 35 One More Thing: Checking for Available Disk Space 35 Summary 36 2 Documents and Data Sharing 39 Recipe: Working with Uniform Type Identifiers 39 Recipe: Accessing the System Pasteboard 45 Recipe: Monitoring the Documents Folder 48 Recipe: Presenting the Activity View Controller 54 Recipe: The Quick Look Preview Controller 63 Recipe: Adding a QuickLook Action 66 Recipe: Using The Document Interaction Controller 69 Recipe: Declaring Document Support 75 Recipe: Creating URL-Based Services 82 Summary 84 3 Core Text 87 Core Text and iOS 87 Attributed Strings 89 Recipe: Basic Attributed Strings 93 Recipe: Mutable Attributed Strings 95 The Mystery of Responder Styles 98 Recipe: Attribute Stacks 100 Recipe: Using Pseudo-HTML to Create Attributed Text 105 Drawing with Core Text 109 Creating Image Cut-Outs 112 Recipe: Drawing Core Text onto a Scroll View 114 Recipe: Exploring Fonts 116 Adding Custom Fonts to Your App 118 Recipe: Splitting Core Text into Pages 119 Recipe: Drawing Attributed Text into a PDF 120 Recipe: Big Phone Text 122 Summary 125 4 Geometry 127 Recipe: Retrieving Points from Bezier Paths 127 Recipe: Thinning Points 129 Recipe: Smoothing Drawings 132 Recipe: Velocity-Based Stroking 135 Recipe: Bounding Bezier Paths 137 Recipe: Fitting Paths 142 Working with Curves 144 Recipe: Moving Items Along a Bezier Path 148 Recipe: Drawing Attributed Text Along a Bezier Path 151 Recipe: View Transforms 154 Recipe: Testing for View Intersection 161 Summary 166 5 Networking 167 Recipe: Secure Credential Storage 167 Recipe: Entering Credentials 171 Recipe: Handling Authentication Challenges 176 Recipe: Uploading Data 177 Recipe: Building a Simple Web Server 181 Recipe: OAuth Utilities 184 Recipe: The OAuth Process 188 Summary 196 6 Images 197 Image Sources 197 Reading Image Data 199 Recipe: Fitting and Filling Images 203 Recipe: Rotating Images 208 Recipe: Working with Bitmap Representations 210 Recipe: Basic Image Processing 215 Recipe: Image Convolution 216 Recipe: Basic Core Image Processing 219 Capturing View-Based Screen Shots 221 Drawing into PDF Files 222 Recipe: Reflection 223 Recipe: Emitters 226 Summary 228 7 Cameras 229 Recipe: Snapping Photos 229 Recipe: Enabling a Flashlight 233 Recipe: Accessing the AVFoundation Camera 235 Recipe: EXIF 242 Image Orientations 247 Recipe: Core Image Filtering 249 Recipe: Core Image Face Detection 251 Recipe: Sampling a Live Feed 257 Summary 260 8 Audio 261 Recipe: Playing Audio with AVAudioPlayer 261 Recipe: Looping Audio 269 Recipe: Handling Audio Interruptions 272 Recipe: Recording Audio 274 Recipe: Recording Audio with Audio Queues 280 Recipe: Picking Audio with the MPMediaPickerController 286 Creating a Media Query 288 Recipe: Using the MPMusicPlayerController 290 Summary 294 9 Connecting to the Address Book 297 The AddressBook Frameworks 297 Recipe: Searching the Address Book 322 Recipe: Accessing Contact Image Data 325 Recipe: Picking People 326 Recipe: Limiting Contact Picker Properties 329 Recipe: Adding and Removing Contacts 331 Modifying and Viewing Individual Contacts 334 Recipe: The "Unknown" Person Controller 335 Summary 338 10 Location 339 Authorizing Core Location 339 Recipe: Core Location in a Nutshell 344 Recipe: Geofencing 348 Recipe: Keeping Track of "North" by Using Heading Values 350 Recipe: Forward and Reverse Geocoding 353 Recipe: Viewing a Location 355 Recipe: User Location Annotations 360 Recipe: Creating Map Annotations 363 Summary 369 11 GameKit 371 Enabling Game Center 371 Recipe: Signing In to Game Center 373 Designing Leaderboards and Achievements 375 Recipe: Accessing Leaderboards 378 Recipe: Displaying the Game Center View Controller 380 Recipe: Submitting Scores 381 Recipe: Checking Achievements 382 Recipe: Reporting Achievements to Game Center 383 Recipe: Multiplayer Matchmaking 385 Recipe: Responding to the Matchmaker 387 Recipe: Creating an Invitation Handler 388 Managing Match State 390 Recipe: Handling Player State Changes 390 Recipe: Retrieving Player Names 392 Game Play 393 Serializing Data 394 Recipe: Synchronizing Data 397 Recipe: Turn-by-Turn Matchmaking 399 Recipe: Responding to Turn-Based Invitations 401 Recipe: Loading Matches 402 Recipe: Responding to Game Play 403 Recipe: Ending Gameplay 407 Recipe: Removing Matches 410 Recipe: Game Center Voice 411 GameKit Peer Services 415 Summary 425 12 StoreKit 427 Getting Started with StoreKit 427 Creating Test Accounts 430 Creating New In-App Purchase Items 431 Building a Storefront GUI 435 Purchasing Items 438 Validating Receipts 443 Summary 445 13 Push Notifications 447 Introducing Push Notifications 447 Provisioning Push 451 Registering Your Application 454 Recipe: Push Client Skeleton 458 Building Notification Payloads 465 Recipe: Sending Notifications 466 Feedback Service 471 Designing for Push 473 Summary 473 Index 475.
The Advanced iOS6