Get the expert guidance you need to begin building native applications for Apple's new iPhone 3G as well as the iPod Touch Apple's iPhone is the hottest mobile device on the planet. More than one million iPhone 3G phones were sold in the first three days of release and millions more are sure to be in the hands of iPhone fans each year. Apple's iPhone SDK has been updated and includes more than one thousand new APIs that developers will want to get their hands on. iPhone SDK 3 Programming shows you how to build great applications for the iPhone and iPod Touch. Inside, veteran mobile developer and Bell Labs scientist Maher Ali begins with a foundational introduction to Objective-C and Cocoa programming, and then guides you through building programs with Apple's iPhone SDK 3. Covers the complete application development process, and highlights all the key device features including the camera, location awareness, and more Completely revised and redesigned with more than 100 new pages of content iPhone's new SDK release contains more than one thousand new APIs you will want to use right away Includes a focused introduction to the Objective-C language and Cocoa frameworks that new iPhone developers need With this advanced resource , you'll get the expert guidance you need to begin building native applications for Apple's new iPhone 3G as well as the iPod Touch. CONTENTS......Page 7 PREFACE......Page 17 1.1.1 Obtaining and installing the SDK......Page 23 1.1.2 Creating a project......Page 24 1.1.3 Familiarizing yourself with the IDE......Page 25 1.1.4 Looking closely at the generated code......Page 27 1.2 Creating Interfaces......Page 28 1.2.1 Interface Builder......Page 29 1.3 Using the Debugger......Page 36 1.4 Getting More Information......Page 37 1.5 Summary......Page 38 Problems......Page 39 2 Objective-C and Cocoa......Page 41 2.1.1 Class declaration......Page 42 2.1.2 How do I use other declarations?......Page 43 2.1.4 Method invocation and definition......Page 44 2.1.5 Important types......Page 45 2.2.1 Creating and deallocating objects......Page 46 2.2.2 Preventing memory leaks......Page 47 2.3 Protocols......Page 49 2.3.1 Protocol conformance......Page 50 2.4.1 Property declaration......Page 51 2.4.2 Circular references......Page 56 2.5 Categories......Page 58 2.7.1 Exceptions......Page 60 2.7.2 Errors......Page 65 2.8 Key-value coding (KVC)......Page 67 2.8.1 An example illustrating KVC......Page 68 2.9 Multithreading......Page 73 2.10 Notifications......Page 77 2.11 The Objective-C Runtime......Page 78 2.11.1 Required header files......Page 79 2.11.2 The NSObject class......Page 80 2.11.3 Objective-C methods......Page 81 2.11.4 Examples......Page 84 Problems......Page 101 3.1 Arrays......Page 105 3.1.1 Immutable copy......Page 108 3.1.2 Mutable copy......Page 110 3.1.3 Deep copy......Page 111 3.1.4 Sorting an array......Page 115 3.2 Sets......Page 118 3.2.1 Immutable sets......Page 119 3.2.2 Mutable sets......Page 121 3.2.3 Additional important methods......Page 122 3.3 Dictionaries......Page 123 3.4 Summary......Page 125 Problems......Page 126 4.1.1 Create a main.m file......Page 127 4.1.2 Create the application delegate class......Page 128 4.1.3 Create the user interface subclasses......Page 129 4.2 Building the HelloWorld Application......Page 130 Problems......Page 135 5.1.1 Useful geometric type definitions......Page 137 5.1.2 The UIScreen class......Page 139 5.1.3 The frame and center properties......Page 140 5.1.4 The bounds property......Page 141 5.3 The Multitouch Interface......Page 143 5.3.1 The UITouch class......Page 144 5.3.3 The UIResponder class......Page 145 5.3.4 Handling a swipe......Page 150 5.3.5 More advanced gesture recognition......Page 154 5.4.1 Using the UIView class animation support......Page 159 5.4.2 Sliding view......Page 163 5.4.4 Transition animation......Page 164 5.5 Drawing......Page 167 Problems......Page 169 6.1.1 UIControl attributes......Page 171 6.1.2 Target-action mechanism......Page 172 6.2 The Text Field......Page 175 6.2.1 Interacting with the keyboard......Page 177 6.2.2 The delegate......Page 180 6.2.3 Creating and working with a UITextField......Page 181 6.3 Sliders......Page 182 6.4 Switches......Page 183 6.5 Buttons......Page 185 6.6 Segmented Controls......Page 186 6.7 Page Controls......Page 189 6.8 Date Pickers......Page 190 Problems......Page 192 7.1.1 The view controller......Page 193 7.1.2 The view......Page 195 7.1.3 The application delegate......Page 196 7.1.4 Summary: creating a simple MVC application......Page 197 7.2.1 A detailed example......Page 199 7.2.2 Some comments on tab bar controllers......Page 204 7.3 Navigation Controllers......Page 208 7.3.1 A detailed example......Page 209 7.3.2 Customization......Page 215 7.4.1 A detailed example......Page 219 Problems......Page 225 8.1 Picker View......Page 227 8.1.1 The delegate......Page 228 8.1.2 An example......Page 229 8.2 Progress Views......Page 233 8.2.1 An example......Page 235 8.3 Scroll View......Page 237 8.4 Text View......Page 239 8.4.2 An example......Page 240 8.5 Alert View......Page 243 8.6 Action Sheet......Page 246 8.7 Web View......Page 247 8.7.1 A simple web view application......Page 248 8.7.2 Viewing local files......Page 252 8.7.3 Evaluating JavaScript......Page 257 8.7.4 The web view delegate......Page 264 Problems......Page 269 9.1 Overview......Page 271 9.2 The Simplest Table View Application......Page 272 9.3 A Table View with both Images and Text......Page 277 9.4 A Table View with Section Headers and Footers......Page 279 9.5 A Table View with the Ability to Delete Rows......Page 280 9.6 A Table View with the Ability to Insert Rows......Page 287 9.7 Reordering Table Rows......Page 292 9.8 Presenting Hierarchical Information......Page 297 9.8.1 Detailed example......Page 300 9.9 Grouped Table Views......Page 307 9.10 Indexed Table Views......Page 310 9.11 Dynamic Table Views......Page 316 9.12 Whitening Text in Custom Cells......Page 319 9.13 Summary......Page 324 Problems......Page 325 10.1 The Home Directory......Page 327 10.2 Enumerating a Directory......Page 328 10.3 Creating and Deleting a Directory......Page 330 10.4 Creating Files......Page 331 10.5 Retrieving and Changing Attributes......Page 334 10.5.1 Retrieving attributes......Page 336 10.5.2 Changing attributes......Page 337 10.6 Working with Resources and Low-level File Access......Page 339 10.7 Summary......Page 342 Problems......Page 343 11.1 Basic Database Operations......Page 345 11.1.2 Table operations......Page 347 11.2 Processing Row Results......Page 349 11.3.1 Preparation......Page 352 11.3.4 Putting it together......Page 353 11.4 User-defined Functions......Page 355 11.5 Storing BLOBs......Page 359 11.6 Retrieving BLOBs......Page 363 Problems......Page 365 12.1.1 XML......Page 367 12.1.2 RSS......Page 369 12.1.3 Configuring the XCode project......Page 372 12.2 Document Object Model (DOM)......Page 373 12.3 Simple API for XML (SAX)......Page 380 12.4 An RSS Reader Application......Page 389 12.5 Putting It Together......Page 391 Problems......Page 393 13.1 The Core Location Framework......Page 395 13.1.1 The CLLocation class......Page 397 13.2 A Simple Location-aware Application......Page 399 13.3.1 A geocoding application......Page 402 13.4 A Tracking Application with Maps......Page 408 13.5 Working with ZIP Codes......Page 414 13.6 Working with the Map Kit API......Page 416 13.6.2 The MKCoordinateRegion structure......Page 417 13.6.3 The MKAnnotation protocol......Page 418 13.6.4 The MKAnnotationView class......Page 419 13.6.5 The MKUserLocation class......Page 421 13.7 Summary......Page 423 Problems......Page 424 14.1.1 Basic accelerometer values......Page 425 14.1.2 Example......Page 427 14.2.1 Playing short audio files......Page 430 14.2.2 Recording audio files......Page 432 14.2.4 Using the media picker controller......Page 434 14.2.5 Searching the iPod library......Page 437 14.3.1 Using the MPMoviePlayerController class......Page 440 14.4 Accessing Device Information......Page 441 14.5.1 Overall approach......Page 442 14.5.2 Detailed example......Page 443 14.6.3 Battery state and level notifications......Page 446 14.6.4 Putting it together......Page 447 14.7 Accessing the Proximity Sensor......Page 448 14.7.3 Retrieving the proximity state......Page 449 Problems......Page 450 15 Internationalization......Page 451 15.1 String Localization......Page 452 15.2 Date Formatting......Page 457 15.2.1 Custom formats......Page 459 15.3 Number Formatting......Page 460 Problems......Page 463 16.1 Text Field Alert View......Page 465 16.2 Table Alert View......Page 469 16.3 Progress Alert View......Page 474 Problems......Page 478 17.1 Determining Network Connectivity......Page 481 17.1.1 Determining network connectivity via EDGE or GPRS......Page 482 17.1.3 Determining network connectivity via WiFi......Page 483 17.2 Uploading Multimedia Content......Page 484 17.3 Computing MD5 Hash Value......Page 487 17.4.1 The application......Page 489 17.5.1 Configuring push notification on the server......Page 496 17.5.2 Configuring the client......Page 503 17.5.3 Coding the client......Page 506 17.6 Sending Email......Page 509 17.6.1 Using the mail composition view controller......Page 510 17.7 Summary......Page 512 Problems......Page 513 18.1 Introduction......Page 515 18.3 Accessing Single-Value Properties......Page 516 18.3.1 Retrieving single-value properties......Page 517 18.4.1 Retrieving multi-value properties......Page 518 18.4.2 Setting multi-value properties......Page 521 18.5 Person and Group Records......Page 522 18.6 Address Book......Page 523 18.8 Person Photo Retriever Application......Page 525 18.9 Using the ABUnknownPersonViewController Class......Page 527 18.10 Using the ABPeoplePickerNavigationController Class......Page 529 18.11 Using the ABPersonViewController Class......Page 531 18.12 Using the ABNewPersonViewController Class......Page 532 18.13 Summary......Page 534 Problems......Page 535 19.1 Core Data Application Components......Page 537 19.2.2 Managed object model......Page 538 19.2.5 Managed object......Page 539 19.2.6 Summary......Page 540 19.3 Using the Modeling Tool......Page 543 19.4.3 Read and update......Page 549 19.5 Working with Relationships......Page 552 19.6.1 The UISearchDisplayController class......Page 553 19.6.2 Main pieces......Page 555 Problems......Page 560 20.1.1 Basic idea......Page 561 20.1.3 Registering an undo operation......Page 562 20.1.4 Hooking into the undo management mechanism......Page 563 20.1.5 Enabling shake to edit behavior......Page 564 20.2.2 First responder status......Page 565 20.2.4 Registering undo actions......Page 566 Problems......Page 568 21.1.2 Creating pasteboards......Page 569 21.2 Pasteboard Items......Page 570 21.2.2 Manipulating pasteboard items......Page 571 21.3.2 The UIMenuController class......Page 573 21.3.3 The role of the view controller......Page 574 21.4.1 The image view......Page 575 21.4.2 The view controller......Page 576 21.5 Summary......Page 580 Problems......Page 581 APPENDICES......Page 583 A Saving and Restoring App State......Page 585 B Invoking External Applications......Page 589 C App Store Distribution......Page 591 D.2 Creating Custom Templates......Page 593 D.2.1 Changing template macro definitions......Page 595 D.3 Build-Based Configurations......Page 596 D.4 Using Frameworks......Page 599 E.1 Adding a Unit Test Target......Page 603 E.2 Adapting to Foundation......Page 604 E.3 The Model......Page 606 E.4 Writing Unit Tests for the Employee Class......Page 608 E.4.1 The setUp and tearDown methods......Page 609 E.4.3 Testing for nullity......Page 610 E.6 Running the Tests......Page 611 F.1.2 Creating the view controller class......Page 613 F.1.3 The application delegate class......Page 616 F.1.4 Building the UI......Page 617 F.2.1 Writing code......Page 631 F.2.2 Building the UI......Page 633 F.2.3 Putting it together......Page 639 Bibliography......Page 641 INDEX......Page 643
Get the expert guidance you need to begin building native applications for Apple's new iPhone 3G as well as the iPod Touch
Apple's iPhone is the hottest mobile device on the planet. More than one million iPhone 3G phones were sold in the first three days of release and millions more are sure to be in the hands of iPhone fans each year. Apple's iPhone SDK has been updated and includes more than one thousand new APIs that developers will want to get their hands on.
iPhone SDK 3 Programming shows you how to build great applications for the iPhone and iPod Touch. Inside, veteran mobile developer and Bell Labs scientist Maher Ali begins with a foundational introduction to Objective-C and Cocoa programming, and then guides you through building programs with Apple's iPhone SDK 3.
- Covers the complete application development process, and highlights all the key device features including the camera, location awareness, and more
- Completely revised and redesigned with more than 100 new pages of content
- iPhone's new SDK release contains more than one thousand new APIs you will want to use right away
- Includes a focused introduction to the Objective-C language and Cocoa frameworks that new iPhone developers need
With this advanced resource, you'll get the expert guidance you need to begin building native applications for Apple's new iPhone 3G as well as the iPod Touch.
Annotation Get the expert guidance you need to begin building native applications for Apples new iPhone 3G as well as the iPod Touch Apples iPhone is the hottest mobile device on the planet. More than one million iPhone 3G phones were sold in the first three days of release and millions more are sure to be in the hands of iPhone fans each year. Apples iPhone SDK has been updated and includes more than one thousand new APIs that developers will want to get their hands on. iPhone SDK 3 Programming shows you how to build great applications for the iPhone and iPod Touch. Inside, veteran mobile developer and Bell Labs scientist Maher Ali begins with a foundational introduction to ObjectiveC and Cocoa programming, and then guides you through building programs with Apples iPhone SDK 3. Covers the complete application development process, and highlights all the key device features including the camera, location awareness, and more Completely revised and redesigned with more than 100 new pages of content iPhones new SDK release contains more than one thousand new APIs you will want to use right away Includes a focused introduction to the ObjectiveC language and Cocoa frameworks that new iPhone developers need With this advanced resource , youll get the expert guidance you need to begin building native applications for Apples new iPhone 3G as well as the iPod Touch I have been developing an iPhone app for a while, and I was at a brick wall with regard to a particular functional implementation that just wouldn't work, no matter how I approached it. After buying this book, I broke through the wall!I found it to be extremely well written, with very clear and complete descriptions of the topics covered. I have been developing mainframe and Windows software for many years, and did some Mac development way back in the early 90's, so I have certainly read my share of technical manuals and "How to" books. "iPhone SDK 3 Programming" is definitely up there near the top. I HIGHLY recommend it for anyone who wants do do more than the simple, everyday iPhone app.