About this Book

iOS 4 in Action is an introductory book, intended to teach the basics of iOS development in a tutorial form. It’s an update of iPhone in Action, which first appeared in 2008, and iPhone and iPad in Action which appeared in 2010. We encourage you to read this book straight through, from chapter 1 to 22. This will introduce the platform, show you how to program for the iPhone and iPad, and walk you through the entire process step by step.

The audience

We’ve done our best to make this book accessible to everyone who is interested in writing native programs for the iPhone and iPad. We hope it will be especially useful to people who are looking to dive into the iPhone/iPad arena, because it allows you to create native applications for all of Apple’s iDevices.

If you want to learn about iOS programming, you should have some experience with programming in general. It’d be best if you’ve worked with C or at least one object-oriented language before, but that’s not a necessity; if you haven’t, you can read our introduction to Objective-C in chapter 2, and you should expect to do some research on your own to clarify things. There’s no need to be familiar with Objective-C, Cocoa, or Apple programming in general. We’ll give you everything you need to become familiar with Apple’s unique programming style. You’ll probably have a legup if you understand object-oriented concepts; but it’s not necessary (and again, you’ll find an introduction in chapter 2).

Roadmap

Chapter 1 explains the iOS SDK, introducing the new features in iOS 4 and covers how to install the iOS SDK.

Chapter 2 kicks things off by highlighting Objective-C, which is the programming language used on the iPhone SDK.

Chapter 3 looks at Xcode 4, the newly released tool in iOS SDK. This integrated development environment does more than just compile your code. It also helps you correct simple errors as you type and provides quick, integrated access to all the iPhone programming documents.

Chapter 4 shifts the focus to mastering Xcode by writing code for applications and debugging with Xcode.

Chapter 5 covers simple view controllers. The basic view controller is an important building block of the MVC paradigm, dividing control from view; and the table view controller provides an easy way to organize information while matching the standard iPhone OS look and feel.

Chapter 6 steps back to talk about user interaction. It covers events, which users generate by touching the screen with one or more fingers, and actions, which happen when users interact with a control object like a button or a slider.

Chapter 7 finishes our look at view controllers by examining two more-advanced possibilities. The tab bar view controller allows for modal selection between multiple pages of content, and the navigation view controller adds hierarchy to tables. Also the universal application design concept will be covered.

Chapter 8 opens the SDK toolkit by talking about data. This includes user input, such as actions and preferences; data storage, such as files; and tools that combine input and storage, such as the devices’ address book.

Chapter 9 goes into more advanced data strategies. In this chapter, you learn how to store complex data in an SQLite database or by using Core Data.

Chapter 10 highlights two of the most unique features on the iPhone and iPad—the accelerometer and the GPS—showing how the iPhone can track movement through space.

Chapter 11 covers another of the device’s strengths—media—by showing how to do basic work with pictures, movies, and sound.

Chapter 12 looks at working with audio. It discusses how to play and record audio using a device’s microphone and speakers.

Chapter 13 provides an extensive look at graphics, centering on the iPhone’s and iPad’s vector graphic language, Quartz 2D. It also offers a brief overview of Core Animation and touches on OpenGL for the iOS.

Chapter 14 examines how you can use the iPhone and iPad to interact with the internet. This chapter moves through the entire hierarchy of internet communication, from low-level host connections to URLs, from web views to modern social languages like XML and JSON.

Chapter 15 takes you through the entire process of creating a multiplayer pong game on the iPhone or iPad. You learn everything about peer-to-peer communication using the Game Kit framework.

Chapter 16 walks through the new Event Kit framework on iOS 4. It also covers a great example of using Grand Central Dispatch with blocks.

Chapter 17 shows you how to handle push notifications in your applications. It also provides a simple example of how to create your own push notification server using PHP.

Chapter 18 takes an in-depth look at the Map Kit framework. It shows you everything you need in order to integrate fully functional Google maps in any application.

Chapter 19 walks you through one of the main methods for creating a virtual store in your applications. Using the Store Kit framework, you learn every step of the process, from creating products to processing purchases.

Chapter 20 covers how to implement and monetize iAd.

Chapters 21 and 22 dive into iOS 4’s core feature: multitasking. We start with the basics of the application life cycle and provide you with a real example using background audio and background location.

The appendixes contain additional information that didn’t fit with the flow of the main text. Appendix A contains a list of SDK objects and what they do. Appendix B features links for many websites of note for iOS programming. Appendix C includes the current information on how to deploy your SDK programs to actual devices. Appendix D shows techniques that you can use to convert iPhone applications into iPad applications.

Code conventions and downloads

Code examples appear throughout this book. Longer listings appear under clear listing headings, and shorter listings appear between lines of text. All code is set in a monospaced font like this to differentiate it from the regular text. Class names have also been set in code font; if you want to type the code into your computer, you’ll be able to make it out clearly.

With the exception of a few cases of abstract code examples, all code snippets began life as working programs. You can download the complete set of programs from www.manning.com/iOS4inAction. You’ll find two ZIP files there, one for each of the SDK programs. We encourage you to try the programs as you read; they include additional code that doesn’t appear in the book and provide more context. In addition, we feel that seeing a program work can elucidate the code required to create it.

The code snippets in this book include extensive explanations. We often include short annotations beside the code; and sometimes numbered cueballs beside lines of code link the subsequent discussion to the code lines.

Software requirements

An Intel-based Macintosh running OS X 10.6 or higher is required to develop iOS applications. You also need to download the iOS SDK, but this is freely downloadable as soon as you sign up with Apple.

The book offers full coverage of the iOS 4 and Xcode 4.

Author Online

Purchase of iOS4 in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the authors and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/iOS4inAction. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum.

Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the authors can take place. It is not a commitment to any specific amount of participation on the part of the authors, whose contribution to the AO forum remains voluntary (and unpaid). We suggest you try asking the authors some challenging questions lest their interest stray!

The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.

About the title

By combining introductions, overviews, and how-to examples, the In Action books are designed to help learning and remembering. According to research in cognitive science, the things people remember are things they discover during self-motivated exploration.

Although no one at Manning is a cognitive scientist, we are convinced that for learning to become permanent it must pass through stages of exploration, play, and, interestingly, retelling of what is being learned. People understand and remember new things, which is to say they master them, only after actively exploring them. Humans learn in action. An essential part of an In Action guide is that it’s example-driven. It encourages the reader to try things out, to play with new code, and explore new ideas.

There is another, more mundane, reason for the title of this book: our readers are busy. They use books to do a job or to solve a problem. They need books that allow them to jump in and jump out easily and learn just what they want just when they want it. They need books that aid them in action. The books in this series are designed for such readers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.216.254