The arrival of the iPhone changed everything. Or, at the very least, it changed the direction of software development for mobile platforms, which is a pretty big thing. It spawned an entire generation of copycat devices and shook an entire multibillion-dollar industry to its knees. Despite this, it still fits in your pocket.
This book gives a rapid introduction to programming for the iPhone and iPod touch for those with some programming experience. If you are developing on the Mac for the first time, drawn to the platform because of the iPhone, or alternatively you are an experienced Mac programmer making the transition to the iPhone, this book is for you.
The book assumes some knowledge of C, or at least passing knowledge of a C-derived language. Additionally, while I do give a crash course, some familiarity with object-oriented programming concepts would be helpful.
This book will guide you through developing your first application for the iPhone, from opening Xcode for the first time to submitting your application to the App Store. You’ll learn about Objective-C and the core frameworks needed to develop for the iPhone by writing applications that use them, giving you a basic framework for building your own applications independently.
Here’s a short summary of the chapters in this book and what you’ll find inside:
This chapter discusses the need for native applications and compares building native applications to building web applications.
This chapter walks you through the process of registering as an iPhone developer and setting up your work environment, from installing Xcode and the iPhone SDK to generating the developer certificates you’ll need to build your applications and deploy them onto your own iPhone or iPod touch.
This chapter allows you to get hands-on as quickly as possible and walks you through building your first Hello World application, including how to deploy and run the application on your iPhone or iPod touch.
This chapter provides a crash course in the basics of the Objective-C language, and if you’re familiar with another C-derived language (and perhaps with object-oriented programming), it should be enough to get you up and running with Objective-C and the Cocoa Touch frameworks.
associated classes are perhaps the most commonly used classes when
building user interfaces for iPhone or iPod touch applications. Due
to the nature of the applications, these classes can be used to
solve a large cross section of problems, and as a result they appear
almost everywhere. In this chapter, we dive fairly deeply into the
table view classes.
After discussing the table view controller in detail, we discuss some of the other view controllers and classes that will become useful when building your applications: simple two-screen views, single-screen tabbed views, modal view controllers, and a view controller for selecting video and images.
This chapter discusses connecting to the Internet, browsing the Web, sending email, and retrieving information.
This chapter discusses how to handle data input, both from the application user and programmatically, and how to parse XML and JSON documents. The chapter also covers storing data in flat files and storing data with the SQLite database engine.
This chapter talks about how to add some final polish to your application and walks you through the process of building your application for distribution, either via ad hoc distribution or for the App Store.
This chapter discusses how to determine what hardware is available and illustrates how to deal with the major sensors on the iPhone and iPod touch: the accelerometer, magnetometer, camera, and GPS.
This chapter walks you through the process of building applications that make use of the Core Location and MapKit frameworks.
This chapter shows you some of the tricks to integrate your application with the iPhone’s software ecosystem, how to present user preferences with Settings Bundles, and how to use custom URL schemes to launch your application. It also discusses how to make use of the Media Player and Address Book.
This chapter deals with the PhoneGap and MonoTouch platforms for building native applications for the iPhone and iPod touch that can be sold on the App Store. The chapter then walks you through the installation process and building your first Hello World application for both platforms.
This chapter provides a collection of pointers to more advanced material on the topics we covered in the book, and material covering some of those topics that we didn’t manage to talk about in the book.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords
Constant width bold
Shows commands or other text that should be typed literally by the user
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Learning iPhone Programming, by Alasdair Allan. Copyright 2010 Alasdair Allan, 978-0-596-80643-9.”
If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at email@example.com.
Please address comments and questions concerning this book to the publisher:
|O’Reilly Media, Inc.|
|1005 Gravenstein Highway North|
|Sebastopol, CA 95472|
|800-998-9938 (in the United States or Canada)|
|707-829-0515 (international or local)|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
Supplementary materials are also available at:
To comment or ask technical questions about this book, send email to:
For more information about our books, conferences, Resource Centers, and the O’Reilly Network, see our website at:
Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from O’Reilly and other publishers, sign up for free at http://my.safaribooksonline.com.
Books do not write themselves, but a book is also not the work of just a single person, despite what it may say on the front cover. I’d like to thank my editor, Brian Jepson. His hard work and constant prodding made the book better than it might otherwise have been. I’d also like to offer more than thanks to my long-suffering wife, Gemma Hobson. Without her support, encouragement, and willingness to make those small (and sometimes larger) sacrifices that an author’s spouse has to make, this book wouldn’t be in your hands today. Thank you. Finally to my son, Alex, who is as yet too young to do more than chew on the cover, daddy’s home. I can only hope for your sake that O’Reilly uses tasty paper.