iPhone SDK Programming: A Beginner's Guide

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Essential Skills--Made Easy! Now you can create your own iPhone and iPod touch applications in no time. iPhone SDK Programming: A Beginner's Guide shows you how to use Cocoa Touch, the Objective-C programming language, and the Xcode development tools. This hands-on guide features several self-contained projects, with the corresponding Xcode available for download and modification. By the end of the book you'll be able to build, test, and debug custom iPhone and iPod touch applications with ease. Designed for Easy Learning Key Skills & Concepts--Chapter-opening lists of specific skills covered in the chapter Ask the Expert--Q&A sections filled with bonus information and helpful tips Try This--Hands-on exercises that show you how to apply your skills Notes--Extra information related to the topic being covered Tips--Helpful reminders or alternate ways of doing things Cautions--Errors and pitfalls to avoid Annotated Syntax--Example code with commentary that describes the programming techniques being illustrated

Author(s): James Brannan
Edition: 5
Publisher: McGraw Hill Professional
Year: 2009

Language: English
Pages: 368

Contents......Page 6
Acknowledgments......Page 14
Introduction......Page 16
1 The iPhone Software Development Kit (SDK)......Page 18
The App Store......Page 19
The Software Development Kit (SDK)......Page 21
Cocoa Touch......Page 22
The iPhone Frameworks......Page 23
Memory and Processor Speed......Page 24
Short-Lived Applications......Page 25
Try This: Getting a Quick Start on iPhone Development......Page 26
Summary......Page 40
2 A C Refresher......Page 42
C Command-Line Programs......Page 43
Try This: Creating a Simple C Program Using Xcode......Page 44
Try This: Creating a Header File......Page 45
Try This: Using Preprocessor Statement......Page 47
Data Types and Operators......Page 48
Control, Functions, and Conditional Statements......Page 49
Arrays and Structures......Page 50
Functions......Page 51
Pointers......Page 52
Try This: Using Pointers......Page 53
Pointers and Arrays......Page 54
Try This: Using an Array with Pointers......Page 55
Summary......Page 56
3 Just Enough Objective-C—Part One......Page 58
Class Interface and Implementation......Page 59
The @interface and @implementation Compiler Directives......Page 60
Try This: Adding sayHello to the Simple Class......Page 62
Interface Anatomy......Page 63
Public, Private, and Protected Instance Variables......Page 64
Understanding Simple Messaging......Page 66
Class and Instance Methods......Page 67
Try This: Adding sayGoodBye as a Class Method to Simple......Page 68
Managing Memory Using Retain and Release......Page 70
Try This: Using Manual Memory Management......Page 73
Instance Variables and Memory......Page 74
Managing Memory Using Autorelease......Page 76
Summary......Page 77
4 Just Enough Objective-C—Part Two......Page 78
Properties......Page 79
Assign......Page 81
Copy......Page 82
Multiple-Argument Messages......Page 83
Try This: Creating a Simple Multiple-Argument Message......Page 84
Dynamic Binding and Dynamic Typing......Page 86
Overriding Methods......Page 87
Using Categories......Page 88
Using Protocols......Page 89
Handling Exceptions......Page 91
Summary......Page 92
5 Deploying to an iPhone, Debugging, and Testing......Page 94
Membership......Page 96
Certificates, Devices, Application IDs, and Provisioning......Page 97
Try This: Deploying an Application to iPhone......Page 100
Using the Debugger......Page 105
Try This: Debugging an Application......Page 110
NSZombieEnabled......Page 113
Try This: Enabling Zombies......Page 115
Instruments—Leaks......Page 117
Find a Memory Leak on iPhone Simulator......Page 118
Deploying Your Application......Page 121
Distributing Your App......Page 122
Summary......Page 124
6 UIApplication and UIApplicationDelegate......Page 126
Try This: Adding a UIView and UIViewController to a UIApplicationDelegate......Page 127
Connecting UIWindow, UIApplication, and UIApplicationDelegate......Page 133
Try This: Exploring MainWindow.xib......Page 134
UIApplication and UIApplicationDelegate......Page 135
Handling Application Life Cycle Events......Page 136
Try This: Handling Application Interruptions......Page 139
Summary......Page 140
7 UIView and UIViewController......Page 142
The UIView Class......Page 143
The UIViewController Class......Page 144
IBOutlet and IBAction......Page 145
Try This: Using a View-based Application Template......Page 146
Try This: Using a Window-based Application Template......Page 148
UIViewController and Application Life Cycle Events......Page 152
Try This: Exploring Several Life Cycle Methods......Page 153
Summary......Page 155
8 UITabBar and UITabBarController......Page 156
UITabBar, UITabBarController, UITabBarItem, and UITabBarControllerDelegate......Page 157
Try This: Using the Tab Bar Application Template......Page 160
Try This: Adding a Tab Bar Item to a Tab Bar Application......Page 162
Try This: Creating a Tab Bar Application from Scratch......Page 164
Try This: Allowing Users to Customize a Tab Bar......Page 167
Summary......Page 172
9 UINavigationBar and UINavigationController......Page 174
UINavigationBar, UINavigationController, and UINavigationItem......Page 177
Try This: Building a Three-View Application Using a Navigation Bar......Page 178
Adding Another View......Page 187
Try This: Duplicating the Utility Application......Page 191
Configuring the Navigation Bar......Page 195
Try This: Using a Navigation Controller in a Tab......Page 196
Summary......Page 201
10 Tables Using UITableView and UITableViewController......Page 202
UITableView......Page 204
UITableViewDelegate......Page 206
UITableViewDataSource......Page 207
Try This: Adopting the UITableViewDelegate and UITableViewDataSource......Page 208
Try This: Using a UITableViewController......Page 215
Grouped Table Style......Page 218
Try This: Grouping......Page 219
Indexing......Page 222
Try This: Indexing......Page 223
Try This: Adding an Image......Page 225
Selecting Rows......Page 227
Try This: Row Selection......Page 228
Try This: Changing Row Height......Page 229
Try This: Accessorizing a Table Cell......Page 230
Try This: Customizing a Cell Using Interface Builder......Page 232
Try This: Using a Table in a Navigation Controller in a Tab......Page 237
Getting to Edit Mode......Page 244
Edit Mode Methods......Page 245
Try This: Editing Rows......Page 247
Summary......Page 256
11 Activity, Progress and Alerting Users......Page 258
Showing Activity—the UIActivityIndicatorView......Page 259
Try This: Using a UIActivityIndicatorView......Page 262
Try This: Using a UIProgressView......Page 266
Alerting Users......Page 273
UIAlertView and UIAlertViewDelegate......Page 274
Try This: Creating a Simple UIAlertView......Page 275
Try This: Using an Alert with Multiple Buttons......Page 277
Try This: Using a UIActionSheet......Page 279
Try This: Adding an Application Badge......Page 282
Summary......Page 284
12 Controls—Part One......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 294
UIToolBar......Page 295
Try This: Creating a UIToolbar......Page 297
UISwitch......Page 299
Continuous Property......Page 300
Try This: Using a Switch and a Slider......Page 301
UITextField......Page 304
Try This: Using UITextField (with a Number Pad)......Page 306
UITextView......Page 311
Try This: Using a UISegmentedControl......Page 312
UIWebView......Page 314
UIWebViewDelegate......Page 315
Try This: Creating a Simple Web Browser......Page 316
Summary......Page 319
13 Controls—Part Two: Using Pickers and Using the Camera......Page 320
Date Pickers......Page 321
Try This: Using a Date Picker......Page 325
Try This: Using a UIDatePicker in Timer Mode......Page 329
UIPickerView......Page 333
Try This: Using a Picker......Page 334
Try This: Using a UIPickerView with Two Components......Page 339
Try This: Loading UIImageViews into a UIPickerView......Page 342
UIImagePickerController......Page 345
UIImagePickerControllerDelegate......Page 346
Try This: Using the UIImagePickerController......Page 347
Summary......Page 355
14 Application Settings......Page 356
Try This: Creating a Settings Bundle......Page 358
Settings Field Types......Page 362
Try This: Adding a PSTextFieldSpecifier......Page 363
PSMultiValueSpecifier......Page 364
Try This: Adding a PSMultiValueSpecifier......Page 365
PSToggleSwitchSpecifier......Page 366
Try This: Adding a PSToggleSwitchSpecifier......Page 367
Try This: Adding a PSSliderSpecifier......Page 369
Try This: Adding a PSChildPaneSpecifier......Page 371
Reading Settings Using NSUserDefaults......Page 373
Try This: Reading the Settings Bundle......Page 374
Summary......Page 375
15 Property Lists and Archiving......Page 376
Directories......Page 377
Try This: Preserving an NSArray......Page 379
NSPropertyListSerialization......Page 381
Try This: Preserving to an XML Property List......Page 382
Archiving......Page 384
Protocols to Adopt......Page 385
NSKeyedArchiver and NSKeyedUnarchiver......Page 386
Try This: Archiving and Unarchiving an Object......Page 387
Try This: Archiving and Unarchiving an Object Hierarchy......Page 390
Summary......Page 394
16 Data Persistence Using SQLite......Page 396
Try This: Creating a Simple Database Using FireFox SQLite Manager......Page 397
Opening the Database......Page 401
Statements, Preparing Statements, and Executing Statements......Page 402
Select......Page 403
Try This: Opening and Querying a Database......Page 404
SQLite Binding, Inserting, Updating, and Deleting......Page 411
Try This: Inserting, Updating, and Deleting Records......Page 413
Summary......Page 421
17 Core Data......Page 422
Creating a Model......Page 423
Entities......Page 424
Try This: Adding Entities to a Core Data Model......Page 425
Relationships......Page 427
Try This: Modeling Relationships......Page 429
Model, Context, and Store......Page 430
NSManagedObjectContext......Page 431
Try This: Generating NSManagedObjects from Entities......Page 432
Try This: Adding Core Data to the Application's Code......Page 434
Saving Changes......Page 437
NSPredicate......Page 438
NSSortDescriptor......Page 439
Try This: Adding, Fetching, and Deleting Entities......Page 440
Summary......Page 449
18 Multimedia......Page 450
AudioServicesPlaySystemSound......Page 451
AVAudioPlayer and AVAudioPlayerDelegate......Page 453
Try This: Playing a Sound and an MP3......Page 454
Media Data Classes......Page 457
Selecting Multimedia......Page 458
Playing Multimedia - MPMusicPlayerController......Page 459
Try This: Using the Media Picker and Media Player......Page 460
MPMoviePlayerController......Page 466
Try This: Play a Video......Page 467
Summary......Page 469
A......Page 470
C......Page 471
D......Page 472
I......Page 473
L......Page 474
M......Page 475
P......Page 476
S......Page 477
T......Page 478
U......Page 479
Z......Page 481