Excerpt
Preface Preface
Few platforms match the iPhones unique developer technologies. It combines OS X-based mobile computing with an innovative multitouch screen, location awareness, an onboard accelerometer, and more. When Apple introduced the iPhone Cocoa Touch SDK beta in early March 2008, developers responded in numbers that brought Apples servers to its knees. Apple delivered more than one hundred thousand SDK downloads in less than one week. The iPhone Developers Cookbook was written to address this demand, providing an accessible resource for those new to iPhone programming.
Who This Book Is For
This book is written for new iPhone developers with projects to get done and a new unfamiliar SDK in their hands. Although each programmer brings different goals and experiences to the table, most developers end up solving similar tasks in their development work: “How do I build a table?”; “How do I create a secure keychain entry?”; “How do I search the Address Book?”; “How do I move between views?”; and “How do I use Core Location?”
The iPhone Developers Cookbook is aimed squarely at anyone just getting started with iPhone programming. With its clear, fully documented examples, it will get you up to speed and working productively. It presents already tested ready-to-use solutions, letting programmers focus on the specifics of their application rather than on boilerplate tasks.
How This Book Is Structured
This book offers single-task recipes for the most common issues new iPhone developers face: laying out interface elements, responding to users, accessing local data sources, and connecting to the Internet. The cookbook approach delivers cut-and-paste convenience. Programmers can add source recipes into their projects and then customize them to their needs. Each chapter groups related tasks together. Readers can jump directly to the kind of solution theyre looking for without having to decide which class or framework best matches that problem.
Heres a rundown of what youll find in this books chapters:
Chapter 1: Getting Started with the iPhone SDK
Chapter 1 introduces the iPhone SDK and explores the iPhone as a delivery platform, limitations and all. It explains the breakdown of the standard iPhone application and enables you to build your first Hello World style samples.
Chapter 2: Views
Chapter 2 introduces iPhone views, objects that live on your screen. You see how to lay out, create, and order your views to create backbones for your iPhone applications. You read about view hierarchies, geometries, and animations as well as how users can interact with views through touch.
Chapter 3: View Controllers
The iPhone paradigm in a nutshell is this: small screen, big virtual worlds. In Chapter 3, you discover the various UIViewController classes that enable you to enlarge and order the virtual spaces your users interact with. You learn how to let these powerful objects perform all the heavy lifting when navigating between iPhone application screens.
Chapter 4: Alerting Users
The iPhone offers many ways to provide users with a heads up, from pop-up dialogs and progress bars to audio pings and status bar updates. Chapter 4 shows how to build these indications into your applications and expand your user-alert vocabulary.
Chapter 5: Basic Tables
Tables provide an interaction class that works particularly well on a small, cramped device. Many, if not most, apps that ship with the iPhone and iPod touch center on tables, including Settings, YouTube, Stocks, and Weather. Chapter 5 shows how iPhone tables work, what kinds of tables are available to you as a developer, and how you can use table features in your own programs.
Chapter 6: Advanced Tables
iPhone tables do not begin and end with simple scrolling lists. You can build tables with titled sections, with multiple scrolling columns, and more. You can add controls such as switches, create translucent cell backgrounds, and include custom fonts. Chapter 6 starts from where “Basic Tables” left off. It introduces advanced table recipes for you to use in your iPhone programs.
Chapter 7: Media
As youd expect, the iPhone can load and display media from a wide variety of formats. It does music; it does movies. It handles images and Web pages. You can present PDF documents and photo albums and more. Chapter 7 shows way after way that you can import or download data into your program and display that data using the iPhones multitouch interface.
Chapter 8: Control
The UIControl class provides the basis for many iPhones interactive elements, including buttons, text fields, sliders, and switches. Chapter 8 introduces controls and their use, both through well-documented SDK calls and through less-documented ones.
Chapter 9: People, Places, and Things
In addition to standard user interface controls and media components that youd see on any computer, the iPhone SDK provides a number of tightly focused developer solutions specific to iPhone and iPod touch delivery. Chapter 9 introduces the most useful of these, including Address Book access (“people”), core location (“places”), and sensors (“things”).
Chapter 10: Connecting to Services
As an Internet-connected device, the iPhone is particularly suited to subscribing to Web-based services. Apple has lavished the platform with a solid grounding in all kinds of network computing services and their supporting technologies. The iPhone SDK handles sockets, password keychains, SQL access, XML processing, and more. Chapter 10 surveys common techniques for network computing and offering recipes that simplify day-to-day tasks.
- Chapter 11: One More Thing: Programming Cover Flow
Although Cover Flow is not officially included in the iPhone SDK, it offers one of the nicest and most beautiful features of the iPhone experience. With Cover Flow, you can offer your users a gorgeously intense visual selection experience that puts standard scrolling lists to shame. Chapter 11 introduces Cover Flow and shows how you can use it in your applications.
Prerequisites
Here are basics you need on hand to begin programming for the iPhone or iPod touch:
- A copy of Apples iPhone SDK. Download your copy of the iPhone SDK from Apples iPhone Dev Center (http://developer.apple.com/iphone/). You must join Apples (free) developer program before you download.
- An iPhone or iPod touch. Although Apple supplies a simulator as part of its SDK, you really do need to have an actual unit to test on if youre going to develop any serious software. Youll be able to use the cable that shipped with your iPhone or iPod touch to tether your unit to the computer and install the software youve built.
- An Apple iPhone Developer License. You will not be able to test your software on an actual iPhone or iPod touch until you join Apples iPhone Developer program (http://developer.apple.com/iphone/program). Members receive a certificate that allows them to sign their applications and download them to the platforms in question for testing and debugging. The program costs $99/year for individuals and companies, $299/year for in-house enterprise development.
- An Intel-based Macintosh running Leopard. The SDK requires a Macintosh running Leopard OS X 10.5.3 or later. Apple requires an Intel-based computer in 32-bit mode. Many features do not work properly on PPC-based Macs or Intel Macs in 64-bit mode. Reserve plenty of disk space and at least 1GB of RAM.
- At least one available USB 2.0 port. This enables you to tether your development iPhone or iPod touch to your computer for file transfer and testing.
- An Internet connection. This connection enables you to test your programs with a live WiFi connection as well as with EDGE.
- Familiarity with Objective-C. The SDK is built around Objective-C 2.0. The language is based on standard C with object-oriented extensions. If you have any object-oriented and C background, making the move to Objective-C is both quick and simple. Consult any Objective-C/Cocoa reference book to get up to speed.
Note - Although the SDK supports development for the iPhone and iPod touch, as well as possible yet-to-be-announced platforms, this book refers to the target platform as iPhone for the sake of simplicity. When developing for the touch, most material is applicable. This excludes certain obvious features such as telephony and onboard speakers. This book attempts to note such exceptions in the manuscript.
Contacting the Author
If you have any comments or questions about this book, please drop me an e-mail message at [email protected] or stop by http://www.ericasadun.com. My Web site hosts many of the applications discussed in this book. Please feel free to visit, download software, read documentation, and leave your comments.
© Copyright Pearson Education. All rights reserved.