IOS SDK Programming a Beginners Guide
9780071759090, 0071759093, 9780071759083, 0071759085
Essential Skills--Made Easy! Develop, test, and debug iPhone, iPad, and iPod touch applications with help from this prac
302
27
3MB
English
Pages 506
[529]
Year 2011
Report DMCA / Copyright
DOWNLOAD PDF FILE
Table of contents :
Contents......Page 10
Acknowledgments......Page 18
Introduction......Page 20
1 The iOS Software Development Kit (SDK)......Page 24
The App Store......Page 25
The Software Development Kit (SDK)......Page 27
Objective-C, Foundation Framework, Cocoa Touch, and UIKit......Page 28
The iOS Frameworks......Page 29
Small Screen......Page 31
Relevant Documentation......Page 32
Try This: Getting a Quick Start on iOS Development......Page 33
Summary......Page 46
2 A C Refresher......Page 48
Try This: Creating a Simple C Program Using Xcode......Page 50
C Comments......Page 51
Try This: Creating a Header File......Page 52
Try This: Using Preprocessor Statements......Page 54
Data Types and Operators......Page 55
Control, Functions, and Conditional Statements......Page 56
Functions......Page 58
Pointers......Page 59
Try This: Using Pointers......Page 60
Dereferencing a Pointer......Page 61
Try This: Using an Array with Pointers......Page 62
Summary......Page 63
3 Just Enough Objective-C: Part One......Page 64
Class Interface and Implementation......Page 65
Try This: Generating an Objective-C Class’ Interface and Implementation......Page 66
Method Declaration and Definition......Page 67
Try This: Adding SayHello to the Simple Class......Page 68
Implementation Anatomy......Page 69
Understanding Simple Messaging......Page 71
Nested Arguments......Page 72
Class and Instance Methods......Page 73
Try This: Adding sayGoodBye as a Class Method......Page 74
The alloc and init Methods......Page 75
Managing Memory Using Retain and Release......Page 76
Try This: Using Manual Memory Management......Page 78
Instance Variables and Memory......Page 80
Managing Memory Using Autorelease......Page 81
Summary......Page 82
4 Just Enough Objective-C: Part Two......Page 84
Properties......Page 85
Assign......Page 87
Copy......Page 88
Releasing Properties......Page 89
Try This: Creating a Simple Multiple-Argument Message......Page 90
The id Type......Page 92
Overriding Methods......Page 93
Overloading Methods......Page 94
Using Protocols......Page 95
Handling Exceptions......Page 97
Summary......Page 98
5 Deploying to an iPhone, Debugging, and Testing......Page 100
Membership......Page 102
Certificates, Devices, Application IDs, and Provisioning......Page 103
Try This: Deploying an Application to iPhone......Page 106
Debugging......Page 111
Using the Debugger......Page 112
Try This: Debugging an Application......Page 116
NSZombieEnabled......Page 120
Try This: Enabling Zombies......Page 121
Instruments—Leaks......Page 124
Try This: Find a Memory Leak......Page 125
Ad Hoc Deployment and Testing......Page 127
Distributing Your App via the App Store......Page 130
Summary......Page 131
6 UIApplication and UIApplicationDelegate......Page 132
Try This: Adding a UIView and UIViewController to a UIApplicationDelegate......Page 133
Connecting UIWindow, UIApplication, and UIApplicationDelegate......Page 140
Try This: Exploring Main Window.xib......Page 141
UIApplication and UIApplicationDelegate......Page 142
The main.m File......Page 143
Handling Application Life Cycle Events......Page 144
Application Interruptions......Page 146
Try This: Handling Application Interruptions......Page 148
Summary......Page 149
7 UIView and UIViewController......Page 150
The UIView Class......Page 151
The UIViewController Class......Page 152
IBOutlet and IBAction......Page 153
Try This: Using a View-Based Application Template......Page 154
Try This: Using a Window-Based Application Template......Page 156
UIViewController and Application Life Cycle Events......Page 160
Try This: Exploring Several Life Cycle Methods......Page 161
Summary......Page 163
8 UITabBar and UITabBarController......Page 164
UITabBar, UITabBarController, UITabBarItem, and UITabBarControllerDelegate......Page 165
Try This: Using the Tab Bar Application Template......Page 168
Try This: Adding a Tab Bar Item to a Tab Bar Application......Page 170
Try This: Creating a Tab Bar Application from Scratch......Page 171
Try This: Allowing Users to Customize a Tab Bar......Page 174
Summary......Page 179
9 UINavigationBar and UINavigationController......Page 182
UINavigationBar, UINavigationController, and UINavigationItem......Page 185
Try This: Building a Three-View Application Using a Navigation Bar......Page 186
Adding Another View......Page 195
Try This: See How a Utility Application Uses NavigationBar......Page 199
Configuring the Navigation Bar......Page 200
Try This: Using a Navigation Controller in a Tab......Page 201
Summary......Page 206
10 Tables Using UITableView and UITableViewController......Page 208
UITableViewDataSource......Page 212
Try This: Adopting the UITableViewDelegate and UITableViewDataSource......Page 214
Try This: Adding a Delegate and Data Source......Page 217
Try This: Using a UITableViewController......Page 221
Grouping and Indexing......Page 224
Try This: Grouping......Page 225
Try This: Indexing......Page 228
Try This: Adding an Image......Page 230
Try This: Row Selection......Page 232
Try This: Changing Row Height......Page 233
Accessorizing Table Cells......Page 234
Try This: Accessorizing a Table Cell......Page 235
Customizing a Table Cell......Page 236
Try This: Customizing a Cell Using Interface Builder......Page 237
Try This: Using a Table in a Navigation Controller in a Tab......Page 242
Edit Mode Methods......Page 249
Try This: Editing Rows......Page 251
Summary......Page 259
11 Activity Progress and Alerting Users......Page 260
Showing Activity—the UIActivityIndicatorView......Page 262
Try This: Using a UIActivitylndicatorView......Page 264
Try This: Using a UIProgress View......Page 267
Alerting Users......Page 274
UIAlertView and UIAlertViewDelegate......Page 275
Try This: Creating a Simple UIAlertView......Page 277
Try This: Using an Alert with Multiple Buttons......Page 279
Try This: Using a UIActionSheet......Page 280
Try This: Adding an Application Badge......Page 283
Summary......Page 284
12 Controls—Part One: Using Buttons, Sliders, Switches, and Text Fields......Page 286
UIButton with a Background Image and Image......Page 288
Try This: Using a Custom Button Background Image and Image......Page 289
Button Types......Page 293
UIToolBar......Page 294
Try This: Creating a UIToolbar......Page 296
UISlider......Page 299
Try This: Using a Switch and a Slider......Page 300
UITextField......Page 303
Try This: Using UITextField (with a Number Pad)......Page 305
UITextView......Page 309
Try This: Using a UISegmentedControl......Page 310
The Web View......Page 312
UIWebViewDelegate......Page 313
Try This: Creating a Simple Web Browser......Page 314
Summary......Page 317
13 Controls—Part Two: Using Pickers and Using the Camera......Page 318
Date Pickers......Page 319
Try This: Using a Date Picker......Page 322
Try This: Using a UIDatePicker in Timer Mode......Page 326
UIPickerView......Page 329
Try This: Using a Picker......Page 331
Try This: Using a UIPickerView with Two Components......Page 335
Try This: Loading UIImageViews into a UIPickerView......Page 339
Using the Camera: UIImagePickerController......Page 341
UIImagePickerControllerDelegate......Page 342
Try This: Using the UIImagePickerController......Page 343
Try This: Using Notifications......Page 349
Summary......Page 351
14 Application Settings......Page 352
The Settings Bundle......Page 354
Try This: Creating a Settings Bundle......Page 355
Settings Field Types......Page 358
Try This: Adding a PSTextFieldSpecifier......Page 359
Try This: Adding a PSMultiValueSpecifier......Page 361
Try This: Adding a PSToggleSwitchSpecifier......Page 363
Try This: Adding a PSSliderSpecifier......Page 365
Try This: Adding a PSChildPaneSpecifier......Page 367
Reading Settings Using NSUserDefaults......Page 369
Try This: Reading the Settings Bundle......Page 370
Summary......Page 371
15 Property Lists and Archiving......Page 372
Directories......Page 373
Property Lists......Page 374
Try This: Preserving an NSArray......Page 375
NSPropertyListSerialization......Page 377
Try This: Preserving to an XML Property List......Page 378
Protocols to Adopt......Page 381
NSKeyedArchiver and NSKeyedUnarchiver......Page 382
Try This: Archiving and Unarchiving an Object......Page 383
Try This: Archiving and Unarchiving an Object Hierarchy......Page 387
Multitasking and Saving Application State......Page 391
Summary......Page 392
16 Data Persistence Using SQLite......Page 394
Try This: Creating a Simple Database Using FireFox SQLite Manager......Page 395
Opening the Database......Page 399
Statements, Preparing Statements, and Executing Statements......Page 400
Select......Page 401
Try This: Opening and Querying a Database......Page 402
SQLite Binding, Inserting, Updating, and Deleting......Page 409
Try This: Inserting, Updating, and Deleting Records......Page 411
Try This: Inserting Records......Page 413
Try This: Updating Records......Page 415
Try This: Deleting Records......Page 418
Summary......Page 420
17 Core Data......Page 422
Core Data in Brief......Page 423
Entities......Page 424
Relationships......Page 425
Try This: Adding Entities and Relationships to a Core Data Model......Page 426
NSPersistentStoreCoordinator......Page 431
NSFetchRequest......Page 432
NSPredicate......Page 433
NSSortDescriptor......Page 434
Try This: Fetching All AKCGroup Entities......Page 435
Saving Changes......Page 438
Updating Entities......Page 439
Try This: Adding Navigation and AKCGroup Editing......Page 440
Try This: Adding Navigation and Editing for a List of Breeds......Page 447
Try This: Adding a Breed Detail View......Page 451
Distributing Core Data with Your App......Page 453
What Next?......Page 455
Summary......Page 456
18 Multimedia......Page 458
Playing Sounds......Page 459
AudioServicesPlaySystemSound......Page 460
AVAudioPlayer and AVAudioPlayerDelegate......Page 461
Try This: Playing a Sound and an MP3......Page 462
Media Data Classes......Page 465
Selecting Multimedia......Page 466
Playing Multimedia: MPMusicPlayerController......Page 467
Try This: Using the Media Picker and Media Player......Page 468
MPMoviePlayerController......Page 474
Try This: Play a Video......Page 475
Summary......Page 478
19 Universal Applications for the iPad......Page 480
Try This: Building an App for iPad and iPhone......Page 483
Try This: Reacting to Orientation Changes......Page 486
Icons and Default Screens......Page 487
Try This: Add a Split View......Page 488
Using Popovers for Information or Editing......Page 500
Try This: MoviePlayer Centered on the iPad Screen......Page 501
External Display......Page 504
Working with Documents......Page 505
Summary......Page 506
A......Page 508
C......Page 510
D......Page 512
E......Page 513
I......Page 514
M......Page 516
N......Page 518
O......Page 520
P......Page 521
R......Page 522
S......Page 523
T......Page 524
U......Page 525
V......Page 528
Z......Page 529