Home > Store

The iOS 5 Developer's Cookbook: Expanded Electronic Edition: Essentials and Advanced Recipes for iOS Programmers

Register your product to gain access to bonus material or receive a coupon.

The iOS 5 Developer's Cookbook: Expanded Electronic Edition: Essentials and Advanced Recipes for iOS Programmers

eBook (Watermarked)

  • Sorry, this book is no longer in print.
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Not for Sale

Description

  • Copyright 2012
  • Dimensions: 7" x 9"
  • Edition: 1st
  • eBook (Watermarked)
  • ISBN-10: 0-13-302834-8
  • ISBN-13: 978-0-13-302834-8

This title contains the standard edition of The iOS 5 Developer’s Cookbook PLUS nine additional chapters on advance content. If you already have the eBook edition of The iOS 5 Developer’s Cookbook, you can purchase The iOS 5 Developer’s Cookbook: The Additional Recipes (ISBN: 9780133028393), which only contains the extra chapters, at a low cost.

In this expanded ebook, best-selling author and iOS development guru Erica Sadun brings together all the information you need to quickly start building successful iOS apps for iPhone, iPad, and iPod touch. Sadun has thoroughly revised her best-selling book to focus on powerful new iOS 5 features, APIs, and frameworks, the latest version of Objective-C, and Apple’s breakthrough Xcode 4 toolset. The iOS 5 Developer's Cookbook: Expanded Electronic Edition is packed with ready-made code solutions for the iOS 5 development challenges you’re most likely to face, eliminating trial-and-error and helping you build reliable apps from the very beginning. Sadun teaches each new concept and technique through robust code that is easy to reuse and extend. This isn't just cut-and-paste: Using her examples, Sadun fully explains both the “how” and “why” of effective iOS 5 development. Her tested recipes address virtually every major area of iOS development, from user interface design to view controllers, gestures, and touch to networking and security. This expanded ebook edition adds chapters on documents and data sharing; the Address Book; iCloud; Core Location and MapKit; Audio, Video, and MediaKit; Push Notifications; Accessibility; In-app purchasing with StoreKit; and GameKit. Whatever your iOS development experience, it will give you all the expert answers and reliable code you’ll need to jumpstart any iOS 5 project!

Sample Content

Online Sample Chapter

The iOS 5 Developer's Cookbook: Documents and Data Sharing

Table of Contents

Preface xxxv

1 Introducing the iOS SDK 1

iOS Developer Programs 1

Online Developer Program 2

Standard Developer Program 2

Developer Enterprise Program 3

Developer University Program 3

Registering 3

Getting Started 3

Downloading the SDK 4

Development Devices 5

Simulator Limitations 6

Tethering 7

Understanding Model Differences 8

Screen Size 9

Camera 9

Audio 10

Telephony 10

Core Location and Core Motion Differences 10

Vibration Support and Proximity 11

Processor Speeds 11

OpenGL ES 11

Platform Limitations 12

Storage Limits 12

Data Access Limits 13

Memory Limits 13

Interaction Limits 16

Energy Limits 16

Application Limits 17

User Behavior Limits 18

SDK Limitations 18

Using the Provisioning Portal 19

Setting Up Your Team 19

Requesting Certificates 20

Registering Devices 20

Registering Application Identifiers 21

Provisioning 22

Putting Together iPhone Projects 23

The iPhone Application Skeleton 25

main.m 26

Application Delegate 28

View Controller 30

A Note about the Sample Code in This Book 31

iOS Application Components 32

Application Folder Hierarchy 32

The Executable 32

The Info.plist File 33

The Icon and Launch Images 34

Interface Builder Files 37

Files Not Found in the Application Bundle 37

IPA Archives 38

Sandboxes 38

Programming Paradigms 39

Object-Oriented Programming 39

Model-View-Controller 40

Summary 48

2 Objective-C Boot Camp 51

The Objective-C Programming Language 51

Classes and Objects 52

Creating Objects 54

Memory Allocation 54

Releasing Memory 55

Understanding Retain Counts with MRR 56

Methods, Messages, and Selectors 57

Undeclared Methods 57

Pointing to Objects 58

Inheriting Methods 59

Declaring Methods 59

Implementing Methods 60

Class Methods 62

Fast Enumeration 63

Class Hierarchy 63

Logging Information 64

Basic Memory Management 66

Managing Memory with MRR 67

Managing Memory with ARC 70

Properties 71

Encapsulation 71

Dot Notation 71

Properties and Memory Management 72

Declaring Properties 73

Creating Custom Getters and Setters 74

Property Qualifiers 76

Key-Value Coding 78

Key-Value Observing 79

MRR and High Retain Counts 79

Other Ways to Create Objects 80

Deallocating Objects 82

Using Blocks 84

Defining Blocks in Your Code 85

Assigning Block References 85

Blocks and Local Variables 87

Blocks and typedef 87

Blocks and Memory Management with MRR 88

Other Uses for Blocks 88

Getting Up to Speed with ARC 88

Property and Variable Qualifiers 89

Reference Cycles 92

Autorelease Pools 94

Opting into and out of ARC 95

Migrating to ARC 95

Disabling ARC across a Target 96

Disabling ARC on a File-by-File Basis 97

Creating an ARC-less Project from Xcode Templates 97

ARC Rules 98

Using ARC with Core Foundation and Toll Free Bridging 99

Casting between Objective-C and Core Foundation 99

Choosing a Bridging Approach 101

Runtime Workarounds 102

Tips and Tricks for Working with ARC 103

Crafting Singletons 103

Categories (Extending Classes) 104

Protocols 106

Defining a Protocol 106

Incorporating a Protocol 107

Adding Callbacks 107

Declaring Optional Callbacks 107

Implementing Optional Callbacks 108

Conforming to a Protocol 108

Foundation Classes 109

Strings 110

Numbers and Dates 115

Collections 117

One More Thing: Message Forwarding 123

Implementing Message Forwarding 123

House Cleaning 125

Super-easy Forwarding 126

Summary 126

3 Building Your First Project 127

Creating New Projects 127

Building Hello World the Template Way 129

Create a New Project 129

Introducing the Xcode Workspace 132

Review the Project 137

Open the iPhone Storyboard 138

Edit the View 140

Run Your Application 141

Using the Simulator 142

Simulator: Behind the Scenes 144

Sharing Simulator Applications 146

The Minimalist Hello World 146

Browsing the SDK APIs 149

Converting Interface Builder Files to Their Objective-C Equivalents 151

Using the Debugger 153

Set a Breakpoint 153

Open the Debugger 154

Inspect the Label 155

Set Another Breakpoint 156

Backtraces 157

Console 158

Add Simple Debug Tracing 158

Memory Management 158

Recipe: Using Instruments to Detect Leaks 159

Recipe: Using Instruments to Monitor Cached Object Allocations 162

Simulating Low-Memory Conditions 163

Analyzing Your Code 165

From Xcode to Device: The Organizer Interface 165

Devices 165

Summary 167

Provisioning Profiles 168

Device Logs 168

Applications 169

Console 169

Screenshots 170

Building for the iOS Device 170

Using a Development Provision 170

Enable a Device 171

Inspect Your Application Identifier 172

Set Your Device and Code Signing Identity 172

Set Your Base and Deployment SDK Targets 173

Compile and Run the Hello World Application 174

Signing Compiled Applications 175

Detecting Simulator Builds with Compile-Time

Checks 175

Performing Runtime Compatibility Checks 175

Pragma Marks 177

Collapsing Methods 178

Preparing for Distribution 178

Locating and Cleaning Builds 178

Using Schemes and Actions 179

Adding Build Configurations 181

About Ad Hoc Distribution 182

Building Ad Hoc Packages 183

Over-the-Air Ad Hoc Distribution 184

Building a Manifest 184

Submitting to the App Store 186

Summary 188

4 Designing Interfaces 191

UIView and UIWindow 191

Views That Display Data 192

Views for Making Choices 193

Controls 193

Tables and Pickers 195

Bars 195

Progress and Activity 196

View Controllers 196

UIViewController 197

UINavigationController 197

UITabBarController 198

Split View Controllers 198

Page View Controller 199

Popover Controllers 199

Table Controllers 199

Address Book Controllers 200

Image Picker 200

Mail Composition 200

Document Interaction Controller 200

GameKit Peer Picker 201

Media Player Controllers 201

View Design Geometry 201

Status Bar 202

Navigation Bars, Toolbars, and Tab Bars 203

Keyboards and Pickers 205

Text Fields 207

The UIScreen Class 207

Building Interfaces 207

Walkthrough: Building Storyboard Interfaces 208

Create a New Project 208

Add More View Controllers 208

Organize Your Views 209

Update Classes 210

Name Your Scenes 211

Edit View Attributes 211

Add Navigation Buttons 211

Add Another Navigation Controller 213

Name the Controllers 213

Tint the Navigation Bars 214

Add a Button 214

Change the Entry Point 215

Add Dismiss Code 215

Run the App 216

Popover Walkthrough 216

Add a Navigation Controller 216

Change the View Controller Class 217

Customize the Popover View 217

Make the Connections 218

Edit the Code 218

Walkthrough: Building an iOS-based Temperature Converter with IB 220

Create a New Project 220

Add Media 221

Interface Builder 221

Add Labels and Views 222

Enable Reorientation 223

Test the Interface 223

Add Outlets and an Action 223

Add the Conversion Method 225

Update the Keyboard Type 225

Connecting the iPad Interface 226

Walkthrough: Building a Converter Interface by Hand 227

Putting the Project Together 230

Walkthrough: Creating, Loading, and Using Hybrid Interfaces 230

Create a New XIB Interface File 231

Add a View and Populate It 231

Tag Your Views 231

Edit the Code 232

Designing for Rotation 233

Enabling Reorientation 233

Autosizing 235

Autosizing Example 237

Evaluating the Autosize Option 238

Moving Views 239

Recipe: Moving Views by Mimicking Templates 240

One More Thing: A Few Great Interface Builder Tips 243

Summary 245

5 Working with View Controllers 247

Developing with Navigation Controllers and Split Views 247

Using Navigation Controllers and Stacks 249

Pushing and Popping View Controllers 249

The Navigation Item Class 250

Modal Presentation 251

Recipe: Building a Simple Two-Item Menu 252

Recipe: Adding a Segmented Control 253

Recipe: Navigating Between View Controllers 255

Recipe: Presenting a Custom Modal

Information View 258

Recipe: Page View Controllers 262

Book Properties 262

Wrapping the Implementation 263

Exploring the Recipe 264

Recipe: Scrubbing Pages in a Page View Controller 269

Recipe: Tab Bars 271

Recipe: Remembering Tab State 275

Recipe: Building Split View Controllers 278

Recipe: Creating Universal Split View/Navigation Apps 282

Recipe: Custom Containers and Segues 284

Transitioning Between View Controllers 290

One More Thing: Interface Builder and Tab

Bar Controllers 291

Summary 292

6 Assembling Views and Animations 295

View Hierarchies 295

Recipe: Recovering a View Hierarchy Tree 297

Recipe: Querying Subviews 298

Managing Subviews 300

Adding Subviews 300

Reordering and Removing Subviews 300

View Callbacks 301

Recipe: Tagging and Retrieving Views 301

Using Tags to Find Views 302

Recipe: Naming Views 303

Associated Objects 304

Using a Name Dictionary 305

View Geometry 308

Frames 309

Transforms 310

Coordinate Systems 310

Recipe: Working with View Frames 311

Adjusting Sizes 312

CGRects and Centers 313

Other Utility Methods 314

Recipe: Randomly Moving a Bounded View 318

Recipe: Transforming Views 319

Display and Interaction Traits 320

UIView Animations 321

Building UIView Animation Transactions 322

Building Animations with Blocks 323

Conditional Animation 324

Recipe: Fading a View In and Out 324

Recipe: Swapping Views 326

Recipe: Flipping Views 327

Recipe: Using Core Animation Transitions 328

Recipe: Bouncing Views as They Appear 329

Recipe: Image View Animations 331

One More Thing: Adding Reflections to Views 332

Summary 335

7 Working with Images 337

Finding and Loading Images 337

Reading Image Data 339

Recipe: Accessing Photos from the iOS Photo Album 342

Working with the Image Picker 342

Recovering Image Edit Information 344

Recipe: Retrieving Images from Asset URLs 347

Recipe: Snapping Photos and Writing Them to the Photo Album 349

Choosing Between Cameras 351

Saving Pictures to the Documents Folder 353

Recipe: E-mailing Pictures 354

Creating Message Contents 354

Presenting the Composition Controller 356

Automating Camera Shots 358

Using a Custom Camera Overlay 358

Recipe: Accessing the AVFoundation Camera 359

Requiring Cameras 360

Querying and Retrieving Cameras 360

Establishing a Camera Session 361

Switching Cameras 363

Camera Previews 364

Laying Out a Camera Preview 364

EXIF 365

Image Geometry 365

Building Camera Helper 367

Recipe: Adding a Core Image Filter 368

Recipe: Core Image Face Detection 370

Extracting Faces 376

Recipe: Working with Bitmap Representations 377

Drawing into a Bitmap Context 378

Applying Image Processing 380

Image Processing Realities 382

Recipe: Sampling a Live Feed 384

Converting to HSB 386

Recipe: Building Thumbnails from Images 387

Taking View-based Screenshots 390

Drawing into PDF Files 390

Creating New Images from Scratch 391

Recipe: Displaying Images in a Scrollable View 392

Creating a Multi-Image Paged Scroll 395

Summary 396

8 Gestures and Touches 397

Touches 397

Phases 398

Touches and Responder Methods 399

Touching Views 399

Multitouch 400

Gesture Recognizers 400

Recipe: Adding a Simple Direct Manipulation Interface 401

Recipe: Adding Pan Gesture Recognizers 402

Recipe: Using Multiple Gesture Recognizers at Once 404

Resolving Gesture Conflicts 407

Recipe: Constraining Movement 408

Recipe: Testing Touches 409

Recipe: Testing Against a Bitmap 411

Recipe: Adding Persistence to Direct Manipulation Interfaces 413

Storing State 413

Recovering State 415

Recipe: Persistence Through Archiving 416

Recipe: Adding Undo Support 418

Creating an Undo Manager 418

Child-View Undo Support 418

Working with Navigation Bars 419

Registering Undos 420

Adding Shake-Controlled Undo Support 422

Add an Action Name for Undo and Redo (Optional) 422

Provide Shake-To-Edit Support 423

Force First Responder 423

Recipe: Drawing Touches Onscreen 424

Recipe: Smoothing Drawings 426

Recipe: Detecting Circles 429

Creating a Custom Gesture Recognizer 433

Recipe: Using Multitouch 435

Retaining Touch Paths 438

One More Thing: Dragging from a Scroll View 440

Summary 443

9 Building and Using Controls 445

The UIControl Class 445

Kinds of Controls 445

Control Events 446

Buttons 448

Adding Buttons in Interface Builder 449

Art 450

Connecting Buttons to Actions 451

Buttons That Are Not Buttons 452

Building Custom Buttons in Xcode 453

Multiline Button Text 455

Adding Animated Elements to Buttons 456

Recipe: Animating Button Responses 456

Recipe: Adding a Slider With a Custom Thumb 458

Customizing UISlider 459

Adding Efficiency 460

Appearance Proxies 460

Recipe: Creating a Twice-Tappable Segmented Control 465

Recipe: Subclassing UIControl 467

Creating UIControls 468

Tracking Touches 468

Dispatching Events 468

Working with Switches and Steppers 471

Recipe: Building a Star Slider 472

Recipe: Building a Touch Wheel 476

Adding a Page Indicator Control 478

Recipe: Creating a Customizable Paged Scroller 481

Building a Toolbar 486

Building Toolbars in Code 487

iOS 5 Toolbar Tips 489

Summary 489

10 Working with Text 491

Recipe: Dismissing a UITextField Keyboard 491

Text Trait Properties 492

Other Text Field Properties 493

Recipe: Adjusting Views Around Keyboards 495

Recipe: Dismissing Text Views with Custom Accessory Views 498

Recipe: Resizing Views with Hardware Keyboards 500

Recipe: Creating a Custom Input View 503

Recipe: Making Text-Input-Aware Views 508

Recipe: Adding Custom Input Views to Non-Text Views 511

Adding Input Clicks 511

Recipe: Building a Better Text Editor 513

Recipe: Text Entry Filtering 516

Recipe: Detecting Text Patterns 518

Rolling Your Own Expressions 518

Enumerating Regular Expressions 519

Data Detectors 520

Adding Built-in Type Detectors 520

Recipe: Detecting Misspelling in a UITextView 522

Searching for Text Strings 523

Recipe: Dumping Fonts 524

Recipe: Adding Custom Fonts to Your App 525

Recipe: Basic Core Text and Attributed Strings 526

Using Pseudo-HTML to Create Attributed Text 532

Recipe: Splitting Core Text into Pages 536

Recipe: Drawing Core Text into PDF 537

Recipe: Drawing into Nonrectangular Paths 539

Recipe: Drawing Text onto Paths 542

Drawing Text onto Bezier Paths 543

Drawing Proportionately 544

Drawing the Glyph 545

One More Thing: Big Phone Text 551

Summary 554

11 Creating and Managing Table Views 555

Introducing UITableView and UITableView Controller 555

Creating the Table 556

Recipe: Implementing a Basic Table 558

Populating a Table 558

Data Source Methods 559

Reusing Cells 560

Responding to User Touches 560

Selection Color 561

Changing a Table’s Background Color 561

Cell Types 562

Recipe: Building Custom Cells in Interface Builder 563

Adding in Custom Selection Traits 565

Alternating Cell Colors 565

Removing Selection Highlights from Cells 566

Creating Grouped Tables 567

Recipe: Remembering Control State for Custom Cells 567

Visualizing Cell Reuse 570

Creating Checked Table Cells 571

Working with Disclosure Accessories 572

Recipe: Table Edits 574

Displaying Remove Controls 575

Dismissing Remove Controls 575

Handling Delete Requests 576

Supporting Undo 576

Swiping Cells 576

Adding Cells 576

Reordering Cells 579

Sorting Tables Algorithmically 580

Recipe: Working with Sections 581

Building Sections 582

Counting Sections and Rows 583

Returning Cells 583

Creating Header Titles 584

Creating a Section Index 584

Delegation with Sections 585

Recipe: Searching Through a Table 586

Creating a Search Display Controller 586

Building the Searchable Data Source Methods 587

Delegate Methods 589

Using a Search-Aware Index 589

Customizing Headers and Footers 591

Recipe: Adding “Pull-to-Refresh” to Your Table 592

Coding a Custom Group Table 595

Creating Grouped Preferences Tables 595

Recipe: Building a Multiwheel Table 597

Creating the UIPickerView 598

Recipe: Using a View-based Picker 601

Recipe: Using the UIDatePicker 603

Creating the Date Picker 603

One More Thing: Formatting Dates 606

Summary 608

12 A Taste of Core Data 611

Introducing Core Data 611

Creating and Editing Model Files 612

Generating Class Files 614

Creating a Core Data Context 615

Adding Objects 616

Querying the Database 618

Detecting Changes 619

Removing Objects 619

Recipe: Using Core Data for a Table Data Source 620

Recipe: Search Tables and Core Data 623

Recipe: Integrating Core Data Table Views with Live Data Edits 625

Recipe: Implementing Undo/Redo Support with Core Data 628

Summary 632

13 Alerting the User 633

Talking Directly to Your User Through Alerts 633

Building Simple Alerts 633

Alert Delegates 634

Displaying the Alert 636

Kinds of Alerts 636

“Please Wait”: Showing Progress to Your User 637

Using UIActivityIndicatorView 638

Using UIProgressView 639

Recipe: No-Button Alerts 639

Building a Floating Progress Monitor 642

Recipe: Creating Modal Alerts with Run Loops 642

Recipe: Using Variadic Arguments with Alert Views 645

Presenting Simple Menus 646

Scrolling Menus 648

Displaying Text in Action Sheets 648

Recipe: Building Custom Overlays 649

Tappable Overlays 650

Recipe: Basic Popovers 650

Recipe: Local Notifications 652

Alert Indicators 654

Badging Applications 654

Recipe: Simple Audio Alerts 654

System Sounds 655

Vibration 656

Alerts 656

Delays 656

One More Thing: Showing the Volume Alert 658

Summary 659

14 Device Capabilities 661

Accessing Basic Device Information 661

Adding Device Capability Restrictions 662

Recipe: Recovering Additional Device Information 664

Monitoring the iPhone Battery State 666

Enabling and Disabling the Proximity Sensor 667

Recipe: Using Acceleration to Locate “Up” 668

Retrieving the Current Accelerometer Angle Synchronously 670

Calculate a Relative Angle 671

Working with Basic Orientation 671

Recipe: Using Acceleration to Move Onscreen Objects 672

Adding a Little Sparkle 675

Recipe: Core Motion Basics 676

Testing for Sensors 677

Handler Blocks 677

Recipe: Retrieving and Using Device Attitude 680

Detecting Shakes Using Motion Events 681

Recipe: Detecting Shakes via the Accelerometer 683

Recipe: Using External Screens 686

Detecting Screens 687

Retrieving Screen Resolutions 687

Setting Up Video Out 688

Adding a Display Link 688

Overscanning Compensation 688

VIDEOkit 688

One More Thing: Checking for Available Disk Space 692

Summary 693

15 Networking 695

Checking Your Network Status 695

Recipe: Extending the UIDevice Class for Reachability 697

Scanning for Connectivity Changes 700

Recovering IP and Host Information 702

Using Queues for Blocking Checks 705

Checking Site Availability 707

Synchronous Downloads 709

Asynchronous Downloads in Theory 713

Recipe: Asynchronous Downloads 715

Handling Authentication Challenges 721

Storing Credentials 722

Recipe: Storing and Retrieving Keychain Credentials 725

Recipe: Uploading Data 728

NSOperationQueue 728

Twitter 732

Recipe: Converting XML into Trees 733

Trees 733

Building a Parse Tree 734

Using the Tree Results 736

Recipe: Building a Simple Web-based Server 738

One More Thing: Using JSON Serialization 742

Summary 742

16 Documents and Data Sharing 745

Working with Uniform Type Identifiers 745

Determining UTIs from File Extensions 746

Moving From UTI to Extension or MIME Type 747

Testing Conformance 748

Retrieving Conformance Lists 748

Accessing the System Pasteboard 750

Storing Data 751

Storing Common Types 751

Retrieving Data 752

Recipe: Passively Updating the Pasteboard 752

Recipe: Enabling Document File Sharing 754

Recipe: Monitoring the Documents Folder 757

The Document Interaction Controller 760

Creating Document Interaction Controller Instances 761

Document Interaction Controller Properties 763

Providing Document Quick Look Support 764

Providing Printer and Copy Support 764

Recipe: Checking for the Open Menu 766

Declaring Document Support 767

Recipe: Implementing Document Support 768

Exported Type Declarations 772

Creating URL-Based Services 773

Using URL Schemes 773

Service Downsides 773

Cross-Promotion 774

Registering Schemes: Declaring the URL 774

Registering Schemes: Adding the Handler Method 775

Returning Control to a Calling Application 776

Recipe: Adding Custom Settings Bundles—Or Not 776

The Settings App 777

Avoid Sensitive Information 778

Settings Schema 778

Defining a Settings Bundle 779

Settings and Users 782

Checking User Defaults 783

Summary 783

17 Connecting to the Address Book 785

The AddressBook Frameworks 785

AddressBookUI 785

AddressBook and Its Databases 786

Records 786

The Custom ABStandin Class 787

Querying the Address Book 788

Wrapping the AddressBook Framework 788

Working with Record Functions 789

Retrieving and Setting Strings 790

Working with Date Properties 792

Multivalue Record Properties 793

Storing Multivalue Data 796

Working with Multivalue Items 797

Addresses, Social Profile, and Instant-Message Properties 798

Address Book Images 800

Creating, Adding, and Deleting Records 801

Searching for Contacts 803

Sorting Contacts 804

Working with Groups 804

ABContact, ABGroup, and ABContactsHelper 807

Recipe: Searching the Address Book 807

Recipe: Accessing Contact Image Data 810

Recipe: Picking People 811

Recipe: Limiting Contact Picker Properties 814

Recipe: Adding and Removing Contacts 816

Modifying and Viewing Individual Contacts 819

User Edits 819

Delegate Methods 819

Recipe: The “Unknown” Person Controller 820

One More Thing: Adding Random Contact Art 823

Summary 826

18 iCloud Basics 827

Setting Up an iCloud-Compatible Project 827

Determining Your Team Identifier Prefix 828

Containers 829

Retrieving Identifiers in Code 830

How iCloud Works 831

iCloud Container Folders 831

Building a Shared Document Home 832

Writing To and Reading From Ubiquitous Storage 833

Editing iCloud Storage 834

Designing for iCloud Ubiquity 834

Recipe: Trying Out iCloud 835

Working with UIDocument 838

Establishing the Document as a File Presenter 839

Moving to the Cloud 839

Evicting Items from the Cloud 840

Opening and Saving Files 841

Subscribing to UIDocument Notifications 842

Recipe: Subclassing UIDocument 843

Metadata Queries and the Cloud 845

Handy Routines 847

Local URLs 847

Locating the Ubiquitous Documents Folder 847

Retrieving Files 848

Setting Ubiquity 849

Deleting Files 851

Retrieving Modification Dates 853

Recipe: Accessing the Ubiquitous Key-Value Store 853

How Key-Value Stores Work 854

Accessing the Key-Value Store 854

Subscribing to Key-Value Notifications 855

Recipe: UIManagedDocument and Core Data 856

Remove All Context Saves 857

Establish Your Identifiers and URLs 857

Establish the Document 858

Opening the Document 858

Start Observing 859

Summary 864

19 Core Location and MapKit 867

How Core Location Works 867

GPS Positioning 867

Wi-Fi Positioning 868

Cell Tower Positioning 868

Internet Provider Positioning 868

Hybridizing the Approaches 869

Testing Core Location Features 869

Recipe: Core Location in a Nutshell 870

Location Properties 873

Region Detection 874

Recipe: Tracking Speed 874

Recipe: Computing Speed and Distance 876

Recipe: Keeping Track of “North” by Using Heading Values 878

Recipe: Forward and Reverse Geocoding 881

Recipe: Viewing a Location 883

Finding the Best Location Match 885

Recipe: User Location Annotations 888

Recipe: Creating Map Annotations 890

Creating, Adding, and Removing Annotations 890

Annotation Views 891

Customizing Annotation Views 891

Responding to Annotation Button Taps 893

Summary 897

20 Audio, Video, and MediaKit 899

Recipe: Playing Audio with AVAudioPlayer 899

Initializing an Audio Player 899

Monitoring Audio Levels 901

Playback Progress and Scrubbing 902

Catching the End of Playback 903

Recipe: Looping Audio 908

Recipe: Handling Audio Interruptions 911

Audio That Ignores Sleep 913

Recipe: Adding Background Audio 915

Finishing Up Processing 918

Recipe: Recording Audio 919

Recipe: Recording Audio with Audio Queues 925

Recipe: Playing Video with the Media Player 930

Recipe: Recording Video 934

Recipe: Picking and Editing Video 938

Recipe: Picking Audio with the MPMediaPickerController 941

Creating a Media Query 944

Building a Query 944

Using Predicates 945

Recipe: Using the MPMusicPlayerController 946

Summary 950

21 Push Notifications 953

Introducing Push Notifications 953

How Push Works 954

Multiple Provider Support 955

Security 956

Push Limitations 956

Push Notifications Versus Local Notifications 957

Provisioning Push 957

Generate a New Application Identifier 957

Generate Your SSL Certificate 958

Push-Specific Provisions 961

Creating a Push-Compatible Application 962

Registering Your Application 962

Retrieving the Device Token 963

Handling Token Request Errors 963

Responding to Notifications 964

Recipe: Push Client Skeleton 966

Building Notification Payloads 972

Localized Alerts 973

Transforming from Dictionary to JSON 973

Custom Data 974

Receiving Data on Launch 974

Recipe: Sending Notifications 975

Sandbox and Production 976

Feedback Service 980

Designing for Push 981

Summary 982

22 Accessibility 985

Accessibility in Interface Builder 985

Labels 986

Hints 987

Enabling Accessibility 988

Traits 988

Working with Accessibility from Code 988

Testing with the Simulator 989

Broadcasting Updates 991

Testing Accessibility on the iPhone 991

Summary 994

23 StoreKit: In-App Purchasing 995

Getting Started with StoreKit 995

Fulfillment 996

The StoreKit Development Paradox 996

Developing and Testing 998

Submission 998

Creating Test Accounts 998

Creating New In-App Purchase Items 1000

Filling Out the Details Section 1000

Adding Localized Descriptions 1001

Filling Out the Pricing Section 1003

Submitting a Purchase GUI Screenshot 1003

Submitting In-App Purchases Products for Review 1004

Building a Storefront GUI 1004

Purchasing Items 1007

Signing Out of Your iTunes Account for Testing 1008

Regaining Programmatic Control After a Purchase 1008

Registering Purchases 1010

Restoring Purchases 1012

Purchasing Multiple Items 1013

Handling Delays in Registering Purchases 1013

Validating Receipts 1013

Summary 1016

24 GameKit 1019

Enabling Game Center 1019

Testing for Game Center Availability 1020

Testing Game Center Compliance 1020

Designing Leaderboards and Achievements 1022

Building Leaderboards 1022

Creating Achievements 1023

Accessing Leaderboards 1024

The GKLeaderboard Class 1025

Leaderboard View Controller 1026

Submitting Scores 1028

Unlocking Achievements 1028

Checking Achievements 1029

Reporting Achievements (Unlocking) 1030

Resetting Achievements 1031

Matchmaking: Multiplayer GameKit Matches 1032

Matchmaker Required Methods 1033

Starting a Match 1033

Starting the Game 1034

Creating an Invitation Handler 1034

Managing Match State 1036

Player State Changes 1037

Retrieving Player Names 1037

Game Play 1038

Serializing Data 1039

Synchronizing Data 1042

Turn-by-Turn Matches 1044

Starting a Match 1044

View Controller Delegate Methods 1045

Match Found 1048

Ending the Match 1050

Force Quitting Matches 1052

Game Center Voice 1053

Testing for Chat Availability 1053

Establishing a Play and Record Audio Session 1053

Creating a Voice Chat 1054

Starting and Stopping a Chat 1054

Chat State Monitoring 1054

Implementing a Chat Button 1055

Controlling Volume 1056

GameKit Peer Services 1057

GameKit Bluetooth Limitations 1057

Bonjour Sessions 1058

Servers, Clients, Peers 1059

The Peer Connection Process 1059

Sending and Receiving Data 1063

State Changes 1063

Creating a GameKit Helper 1064

Peer-to-Peer Voice Chat 1064

Implementing Voice Chat 1064

Creating an “Online” GameKit Connection 1066

Summary 1067

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020