Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Beginning iOS5 Development.pdf
Скачиваний:
7
Добавлен:
09.05.2015
Размер:
15.6 Mб
Скачать

Chapter 1

Welcome to the Jungle

So, you want to write iPhone, iPod touch, and iPad applications? Well, we can’t say that we blame you. iOS, the core software of all of these devices, is an exciting platform that has been seeing explosive growth since it first came out in 2007. The rise of the mobile software platform means that people are using software everywhere they go. With the release of iOS 5, and the latest incarnation of the iOS software development kit (SDK), things have only gotten better and more interesting.

What This Book Is

This book is a guide to help you get started down the path to creating your own iOS applications. Our goal is to get you past the initial learning curve, to help you understand the way iOS applications work and how they are built.

As you work your way through this book, you will create a number of small applications, each designed to highlight specific iOS features and show you how to control or interact with those features. If you combine the foundation you’ll gain through this book with your own creativity and determination, and then add in the extensive and well-written documentation provided by Apple, you’ll have everything you need to build your own professional iPhone and iPad applications.

TIP: Dave, Jack, and Jeff have a forum set up for this book. It’s a great place to meet likeminded folks, get your questions answered, and even answer other people’s questions. The

forum is at http://iphonedevbook.com. Be sure to check it out!

What You Need

Before you can begin writing software for iOS, you’ll need a few items. For starters, you’ll need an Intel-based Macintosh running Lion (OS X 10.7) or later. Any recent Intelbased Macintosh computer—laptop or desktop—should work just fine.

D.Mark et al., Beginning iOS 5 Development

©Dave Mark, Jack Nutting, Jeff LaMarche 2011

www.it-ebooks.info

2CHAPTER 1: Welcome to the Jungle

You’ll also need to sign up to become a registered iOS developer. Apple requires this step before you’re allowed to download the iOS SDK.

To sign up as a developer, just navigate to http://developer.apple.com/ios/. That will bring you to a page similar to the one shown in Figure 1–1.

Figure 1–1. Apple’s iOS Dev Center web site

www.it-ebooks.info

CHAPTER 1: Welcome to the Jungle

3

First, click the button labeled Log in. You’ll be prompted for your Apple ID. If you don’t have an Apple ID, click the Create Apple ID button, create one, and then log in. Once you are logged in, you’ll be taken to the main iOS development page. Not only will you see a link to the SDK download, but you’ll also find links to a wealth of documentation, videos, sample code, and the like—all dedicated to teaching you the finer points of iOS application development.

The most important tool you’ll be using to develop iOS applications is called Xcode. Xcode is Apple’s integrated development environment (IDE). Xcode includes tools for creating and debugging source code, compiling applications, and performance tuning the applications you’ve written.

You can find a download link for Xcode on http://developer.apple.com/ios/ once you’ve signed up. You can also download Xcode from the Macintosh App Store, which you can access from your Mac’s Apple menu.

SDK VERSIONS AND SOURCE CODE FOR THE EXAMPLES

As the versions of the SDK and Xcode evolve, the mechanism for downloading them will also change. Sometimes the SDK and Xcode are featured as separate downloads; other times, they will be merged as a single download. Bottom line: you want to download the latest released (non-beta) version of Xcode and the iOS SDK.

This book has been written to work with the latest version of the SDK. In some places, we have chosen to use new functions or methods introduced with iOS 5 that may prove incompatible with earlier versions of the SDK. We’ll be sure to point those situations out as they arise in this book.

Be sure to download the latest and greatest source code archives from the book’s web site at http://iphonedevbook.com or from the book’s page on http://apress.com. We’ll update the code as new versions of the SDK are released, so be sure to check the site periodically.

Developer Options

The free SDK download option includes a simulator that will allow you to build and run iPhone and iPad apps on your Mac. This is perfect for learning how to program for iOS. However, the simulator does not support many hardware-dependent features, such as the accelerometer and camera. Also, the free option will not allow you to download your applications onto your actual iPhone or other device, and it does not give you the ability to distribute your applications on Apple’s App Store. For those capabilities, you’ll need to sign up for one of the other options, which aren’t free:

The Standard program costs $99/year. It provides a host of development tools and resources, technical support, distribution of your application via Apple’s App Store, and, most important, the ability to test and debug your code on an iOS device, rather than just in the simulator.

www.it-ebooks.info

4CHAPTER 1: Welcome to the Jungle

The Enterprise program costs $299/year. It is designed for companies developing proprietary, in-house iOS applications and for those developing applications for the Apple’s App Store with more than one developer working on the project.

For more details on these programs, visit http://developer.apple.com/programs/ios and http://developer.apple.com/programs/ios/enterprise to compare the two.

Because iOS supports an always-connected mobile device that uses other companies’ wireless infrastructure, Apple has needed to place far more restrictions on iOS developers than it ever has on Mac developers (who are able—at least as of this writing—to write and distribute programs with absolutely no oversight or approval from Apple). Even though the iPod touch and the Wi-Fi–only versions of the iPad don’t use anyone else’s infrastructure, they’re still subject to these same restrictions.

Apple has not added restrictions to be mean, but rather as an attempt to minimize the chances of malicious or poorly written programs being distributed that could degrade performance on the shared network. Developing for iOS may seem like it presents a lot of hoops to jump through, but Apple has expended quite an effort to make the process as painless as possible. And also consider that $99 is still considerably less than buying, for example, Visual Studio, which is Microsoft’s software development IDE.

This may seem obvious, but you’ll also need an iPhone, iPod touch, or iPad. While much of your code can be tested using the iOS simulator, not all programs can be. And even those that can run on the simulator really need to be thoroughly tested on an actual device before you ever consider releasing your application to the public.

NOTE: If you are going to sign up for the Standard or Enterprise program, you should do it right now. The approval process can take a while, and you’ll need that approval to be able to run your

applications on an actual device. Don’t worry, though, because all the projects in the first several

chapters and the majority of the applications in this book will run just fine on the iOS simulator.

What You Need to Know

This book assumes that you already have some programming knowledge. It assumes that you understand the fundamentals of object-oriented programming (you know what objects, loops, and variables are, for example). It also assumes that you are familiar with the Objective-C programming language. Cocoa Touch, the part of the SDK that you will be working with through most of this book, uses the latest version of Objective-C, which contains several new features not present in earlier versions. But don’t worry if you’re not familiar with the more recent additions to the Objective-C language. We highlight any of the new language features we take advantage of, and explain how they work and why we are using them.

www.it-ebooks.info

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]