1.Why Go Native? 1
Using an App Offline 2
More Access to the Hardware 3
More Access to the Software 4
What You Lose 6
Distribution 7
Apple iOS Developer Program 8
Content 8
Authoring Platform Choices 8
Taking the Plunge 9
2.Welcome to the iOS SDK 11
Hardware and OS Requirements 11
Installing the SDK 12
About iOS Developer Programs 12
Inside the SDK 14
Viewing Developer Documentation 15
Loading Code Samples 18
Setting the Project's Base SDK 21
Trying the iOS Simulator 22
Coming Up... 24
3.Creatinga Test Workbench 25
Creating the Project in Xcode 26
Selecting a Project Type 26
Naming and Saving the New Project 29
Welcome to Your Project 29
Editing Your First Files 31
What the runMyCode:Method Does 34
Building the User Interface 35
Adding a Button to the View 38
Connecting the Button 42
Going for a Test Ride 46
Congratulations 49
4.Structural Overview of an iOS App 51
Where It All Begins:APIs 51
APIs You Already Know 51
The Cocoa Touch APIs 52
Frameworks 53
Foundation Framework 54
UIKit Framework 54
CoreGraphics Framework 55
Adding Frameworks 55
Frameworks Set in Stone 56
Welcome to Class Files 57
The JavaScript Way 57
The Objective-C Way 58
Header File Details 61
Using Xcode to Create DGCar Class Files 65
Editing the@interface Section 68
Message Passing 70
Editing the@implementation Section 70
Integrating the DGCar Class into Workbench 75
Creating Object Instances 76
NSLog()and String Formats 77
Running the Code 78
What About Accessing Instance Variables? 79
Recap 81
5.App Execution Flow 83
Some C Language Roots in an iOS App 83
An Introduction to Delegates 85
How UIApplication Appoints Its Delegate 87
The App's Info.plist File 87
Inside MainWindow.xib 88
iPhone App Development Design Patterns 92
The Model-View-Controller Design Pattern 92
Other Design Patterns 94
The Importance of Views 95
The App Window-—UIWindow 96
Adding Another View to Workbench 97
Recap 106
6.Central Objective-C Concepts:Pointers,Data Types,and Memory Management 107
Pointers 108
Pointers and Memory 108
Pointers and Objective-C Variables 110
Pointer Notation 111
Determining Pointer Usage 113
Data Typing 115
Objective-C Data Types 116
Cocoa Touch Data Types 116
Objective-C Variable Declarations 118
Objective-C Method Declarations 118
The id Data Type 122
Converting Objective-C Data Types 123
Memory Management 125
Cleaning Up After Yourself 125
The Retain Count 127
Autorelease Pools 129
Observing Memory Usage 130
Recap 131
7.C Language Fundamentals 133
Variable Names 133
Variable Scope 136
Instance Variables 137
Local Variables 137
Local Variables in Control Structure Blocks 138
Static Local Variables 140
Global Variables 140
Constant Values 141
Functions 142
C Structures 148
C Arrays 151
Enumerated Types 152
Operators 153
Program Flow Constructions 153
Boolean Values 154
Math Object Equivalents in C 155
Inserting Comments 157
Recap 157
8.Objective-C/Cocoa Touch Fundamentals 159
More About Classes 159
Temporary Objects 160
Subclassing Framework Classes 161
Defining Your Own Custom Subclasses 162
Adding to a Class Without Subclassing—Categories 166
Real Classes in Real Action 168
TheElements Overview 168
TheElements Class File Structure 171
Class Properties 175
Specifying Properties in the Header File 176
Synthesizing Properties in the Implementation File 178
Using Properties 178
Properties in Framework Classes 180
About NSString 181
Creating an NSString 182
JavaScript String Method Equivalents in Objective-C 185
NSMutableString 189
About NSArray 190
Creating an NSArray 192
Retrieving Array Elements 193
JavaScript Array Method Equivalents in Objective-C 193
NSMutableArray 194
About NSDictionary 195
Creating an NSDictionary 195
Retrieving Dictionary Entries 197
NSMutableDictionary 198
Arrays and Dictionaries in Action 199
Recap 201
9.Common JavaScriptTasksinCocoaTouch 203
Formatting Numbers for Display 203
Preformatted Number Styles 204
Rounding Numbers for Display 206
Creating a Date Object 207
Adding a UIDatePicker to Workbench 207
Understanding NSDate 210
Creating a Date Object for a Specific Date 211
Extracting Components from an NSDate Object 213
Creating NSDate Objects from Strings 214
Converting an NSDate to a String 217
Calculating Dates 219
10 Days in the Future 219
Days Between Dares 220
Comparing Dates 221
Downloading Remote Files Asynchronously 222
Example Project 223
Creating the Request 224
Initializing the NSMutableData Object 225
Delegate Methods 226
Downloading Only When Needed 228
Accounting for Fast App Switching 231
Reading and Writing Local Files 233
iOS App Directories 233
Obtaining Directory Paths 235
Obtaining Paths to Files Delivered with Your App 236
Writing Files to Disk 236
Reading Files from Disk 238
Writing and Reading Property List Files 239
Performing File Management Tasks 240
Sorting Arrays 241
Sorting with a Selector 241
Sorting with a Function 243
Sorting Arrays of Dictionaries with NSSortDescriptor 245
Capturing User-Entered Text 246
The Code Portion 247
The Interface Builder Portion 250
Validating Text Entry with Regular Expressions 251
Modifying the Code 253
Modifying the User Interface 255
Using Regular Expressions for Text Search and Replace 255
Dragging a View Around the Screen 258
The Code Portion 259
The Interface Builder Portion 264
Recap 265
A.Getting the Most from Xcode Documentation 267
B.Common Beginner Xcode Compiler Errors 277
Glossary 281
Index 285