Tải bản đầy đủ (.pdf) (801 trang)

Sams Teach Yourself iOS 5 Application Development in 24 Hours potx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (37.05 MB, 801 trang )

www.it-ebooks.info
800 East 96th Street, Indianapolis, Indiana, 46240 USA
John Ray
Sams Teach Yourself
24
in
Hours
iOS
®
5
Application
Development
www.it-ebooks.info
Sams Teach Yourself iOS® 5 Application Development in 24 Hours
Copyright © 2012 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or
transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without
written permission from the publisher. No patent liability is assumed with respect to the use of
the information contained herein. Although every precaution has been taken in the preparation of
this book, the publisher and author assume no responsibility for errors or omissions. Nor is any
liability assumed for damages resulting from the use of the information contained herein.
ISBN-13: 978-0-672-33576-1
ISBN-10: 0-672-33576-X
Library of Congress Cataloging-in-Publication Data is on file.
Printed in the United States of America
First Printing December 2011
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been
appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use
of a term in this book should not be regarded as affecting the validity of any trademark or service
mark.


Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no
warranty or fitness is implied. The information provided is on an “as is” basis. The author and the
publisher shall have neither liability nor responsibility to any person or entity with respect to any
loss or damages arising from the information contained in this book.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk pur-
chases or special sales. For more information, please contact
U.S. Corporate and Government Sales
1-800-382-3419

For sales outside of the U.S., please contact
International Sales

Associate
Publisher
Greg Wiegand
Acquisitions Editor
Laura Norman
Development
Editor
Keith Cline
Managing Editor
Kristy Hart
Project Editor
Andy Beaster
Copy Editor
Keith Cline
Indexer
Larry Sweazy

Proofreader
Karen Gill
Technical Editor
Anne Groves
Publishing
Coordinator
Cindy Teeters
Designer
Gary Adair
Compositor
Nonie Ratcliff
www.it-ebooks.info
Contents at a Glance
Introduction 1
HOUR 1 Preparing Your System and iDevice for Development
5
2 Introduction to Xcode and iOS Simulator
25
3 Discovering Objective-C: The Language of Apple Platforms
59
4 Inside Cocoa Touch
89
5 Exploring X-code’s Interface Builder
117
6 Model-View-Controller Application Design
147
7 Working with Text, Keyboards, and Buttons
175
8 Handling Images, Animation, Sliders, and Steppers
205

9 Using Advanced Interface Objects and Views
231
10 Getting the User’s Attention
261
11 Introducing Multiple Scenes and Popovers
291
12 Making Choices with Toolbars and Pickers
337
13 Advanced Storyboards Using Navigation and
Tab Bar Controllers
385
14 Navigating Information Using Table Views and
Split View Controllers
421
15 Reading and Writing Application Data
463
16 Building Rotatable & Resizable User Interfaces
503
17 Using Advanced Touches and Gestures
531
18 Sensing Orientation and Motion
557
19 Working with Rich Media
583
20 Interacting with Other Applications
629
21 Implementing Location Services
661
22 Building Background-Aware Applications
691

23 Building Universal Applications
717
24 Application Tracing and Debugging
735
Index
755
www.it-ebooks.info
Table of Contents
Introduction 1
Who Can Become an iOS Developer? 2
Who Should Use This Book?
2
What Is (and Isn’t) in This Book?
3
HOUR 1:
Preparing Your System and iDevice for Development 5
Welcome to the iOS Platform 5
Becoming an iOS Developer
9
Creating and Installing a Development Provisioning Profile
14
Running Your First iOS App
19
Developer Technology Overview
20
Further Exploration
22
Summary
23
Q&A

23
Workshop
24
HOUR 2:
Introduction to Xcode and the iOS Simulator 25
Using Xcode 25
Using the iOS Simulator
51
Further Exploration
56
Summary
57
Q&A
57
Workshop
58
HOUR 3:
Discovering Objective-C: The Language of Apple Platforms 59
Object-Oriented Programming and Objective-C 59
Exploring the Objective-C File Structure
64
Objective-C Programming Basics
73
Memory Management and ARC
83
Further Exploration
86
www.it-ebooks.info
Summary 86
Q&A

87
Workshop
88
HOUR 4:
Inside Cocoa Touch 89
What Is Cocoa Touch? 89
Exploring the iOS Technology Layers
91
Tracing the iOS Application Life Cycle
97
Cocoa Fundamentals
99
Exploring the iOS Frameworks with Xcode
108
Further Exploration
113
Summary
113
Q&A
114
Workshop
114
HOUR 5:
Exploring Xcode’s Interface Builder 117
Understanding Interface Builder 117
Creating User Interfaces
123
Customizing the Interface Appearance
129
Connecting to Code

133
Further Exploration
142
Summary
143
Q&A
144
Workshop
144
HOUR 6:
Model-View-Controller Application Design 147
Understanding the Model-View-Controller Paradigm 147
How Xcode Implements MVC
149
Using the Single View Application Template
154
Further Exploration
171
Summary
172
Q&A
172
Workshop
172
Table of Contents
v
www.it-ebooks.info
HOUR 7: Working with Text, Keyboards, and Buttons 175
Basic User Input and Output 175
Using Text Fields, Text Views, and Buttons

177
Further Exploration
200
Summary
201
Q&A
202
Workshop
202
HOUR 8:
Handling Images, Animation, Sliders, and Steppers 205
User Input and Output 205
Creating and Managing Image Animations, Sliders, and Steppers
207
Further Exploration
227
Summary
228
Q&A
228
Workshop
229
HOUR 9:
Using Advanced Interface Objects and Views 231
User Input and Output (Continued) 231
Using Switches, Segmented Controls, and Web Views
236
Using Scrolling Views
252
Further Exploration

258
Summary
259
Q&A
259
Workshop
260
HOUR 10:
Getting the User’s Attention 261
Alerting the User 261
Exploring User Alert Methods
271
Further Exploration
288
Summary
289
Q&A
289
Workshop
290
vi
Sams Teach Yourself iOS 5 Application Development in 24 Hours
www.it-ebooks.info
HOUR 11: Implementing Multiple Scenes and Popovers 291
Introducing Multiscene Storyboards 292
Understanding the iPad Popover
309
Using a Modal Segue
319
Using a Popover

328
Further Exploration
334
Summary
335
Q&A
335
Workshop
336
HOUR 12:
Making Choices with Toolbars and Pickers 337
Understanding the Role of Toolbars 337
Exploring Pickers
341
Using the Date Picker
349
Using a Custom Picker
364
Further Exploration
380
Summary
381
Q&A
381
Workshop
382
HOUR 13:
Advanced Storyboards Using Navigation and Tab Bar Controllers 385
Advanced View Controllers 386
Exploring Navigation Controllers

388
Understanding Tab Bar Controllers
393
Using a Navigation Controller
398
Using a Tab Bar Controller
407
Further Exploration
417
Summary
417
Q&A
418
Workshop
419
Table of Contents
vii
www.it-ebooks.info
HOUR 14: Navigating Information Using Table Views and
Split View Controllers 421
Understanding Tables 422
Exploring the Split View Controller (iPad Only)
430
A Simple Table View Application
433
Creating a Master-Detail Application
443
Further Exploration
460
Summary

460
Q&A
461
Workshop
461
HOUR 15:
Reading and Writing Application Data 463
iOS Applications and Data Storage 463
Data Storage Approaches
465
Creating Implicit Preferences
473
Implementing System Settings
479
Implementing File System Storage
492
Further Exploration
500
Summary
501
Q&A
501
Workshop
502
HOUR 16:
Building Rotatable and Resizable User Interfaces 503
Rotatable and Resizable Interfaces 503
Creating Rotatable and Resizable Interfaces with Interface Builder
508
Reframing Controls on Rotation

513
Swapping Views on Rotation
521
Further Exploration
527
Summary
527
Q&A
528
Workshop
529
viii
Sams Teach Yourself iOS 5 Application Development in 24 Hours
www.it-ebooks.info
HOUR 17: Using Advanced Touches and Gestures 531
Multitouch Gesture Recognition 532
Using Gesture Recognizers
534
Further Exploration
553
Summary
554
Q&A
554
Workshop
554
HOUR 18:
Sensing Orientation and Motion 557
Understanding Motion Hardware 558
Accessing Orientation and Motion Data

560
Sensing Orientation
564
Detecting Tilt and Rotation
568
Further Exploration
579
Summary
580
Workshop
581
HOUR 19:
Working with Rich Media 583
Exploring Rich Media 583
The Media Playground Application
598
Further Exploration
625
Summary
626
Q&A
627
Workshop
627
HOUR 20:
Interacting with Other Applications 629
Extending Application Integration 629
Using Address Book, Email, Twitter, and Maps Oh My
641
Further Exploration

658
Summary
659
Q&A
659
Workshop
660
Table of Contents
ix
www.it-ebooks.info
HOUR 21: Implementing Location Services 661
Understanding Core Location 661
Creating a Location-Aware Application
668
Using the Magnetic Compass
678
Further Exploration
686
Summary
687
Q&A
687
Workshop
688
HOUR 22:
Building Background-Aware Applications 691
Understanding iOS Backgrounding 692
Disabling Backgrounding
696
Handling Background Suspension

697
Implementing Local Notifications
698
Using Task-Specific Background Processing
701
Completing a Long-Running Background Task
708
Further Exploration
714
Summary
715
Q&A
715
Workshop
716
HOUR 23:
Building Universal Applications 717
Universal Application Development 717
Creating a Universal Application (Take 1)
722
Creating a Universal Application (Take 2)
726
Using Multiple Targets
730
Further Exploration
732
Summary
733
Q&A
733

Workshop
734
x
Sams Teach Yourself iOS 5 Application Development in 24 Hours
www.it-ebooks.info
Table of Contents
xi
HOUR 24:
Application Tracing and Debugging 735
Instant Feedback with NSLog 736
Using the Xcode Debugger
738
Further Exploration
752
Summary
753
Q&A
753
Workshop
753
Index 755
www.it-ebooks.info
About the Author
John Ray is currently serving as a Senior Business Analyst and Development Team
Manager for the Ohio State University Research Foundation. He has written numerous
books for Macmillan/Sams/Que, including Using TCP/IP: Special Edition, Teach Yourself
Dreamweaver MX in 21 Days, Mac OS X Unleashed, and Teach Yourself iPad Development in 24
Hours. As a Macintosh user since 1984, he strives to ensure that each project presents the
Macintosh with the equality and depth it deserves. Even technical titles such as Using TCP/IP
contain extensive information about the Macintosh and its applications and have garnered

numerous positive reviews for their straightforward approach and accessibility to beginner
and intermediate users.
You can visit his website at or follow him on Twitter at
#iOSIn24.
www.it-ebooks.info
Dedication
To the crazy ones.
Thank you, Steve Jobs.
Acknowledgments
Thank you to the group at Sams Publishing—Laura Norman, Keith Cline, Anne Groves—for
not giving up on this book, despite the changes, delays, and other challenges that we
encountered along the way. I’m not sure how you manage to keep all of the files, figures,
and information straight, but on this end it looks like magic.
As always, thanks to my family and friends for feeding me and poking me with a stick to
keep me going.
www.it-ebooks.info
We Want to Hear from You!
As the reader of this book, you are our most important critic and commentator. We value
your opinion and want to know what we’re doing right, what we could do better, what
areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass
our way.
You can email or write me directly to let me know what you did or didn’t like about this
book—as well as what we can do to make our books stronger.
Please note that I cannot help you with technical problems related to the topic of this book,
and that due to the high volume of mail I receive, I might not be able to reply to every
message.
When you write, please be sure to include this book’s title and author as well as your name
and phone or email address. I will carefully review your comments and share them with the
author and editors who worked on the book.
E-mail:

Mail: Greg Wiegand
Associate Publisher
Sams Publishing
800 East 96th Street
Indianapolis, IN 46240 USA
Reader Services
Visit our website and register this book at informit.com/register for convenient access to any
updates, downloads, or errata that might be available for this book.
www.it-ebooks.info
Introduction
In less than half a decade, the iOS platform has changed the way that we, the public, think
about our mobile computing devices. Only a few years ago, we were thrilled by phones with
postage-stamp-sized screens, tinny audio, built-in tip calculators, and text-based web brows-
ing. Times have indeed changed. With full-featured applications, an interface architecture
that demonstrates that small screens can be effective workspaces, and touch controls unri-
valed on any platform, the iPhone brings us the convenience of desktop computing within
our pockets.
When Steve Jobs introduced the iPad, people laughed at the name and the idea that “a big
iPod Touch” could be magical. In the 2 years that have passed since its introduction, the
iPad has become the de facto standard for tablet computing and shows no signs of slowing
down. Rarely a week goes by when I don’t read a review of a new app that is described as
“magical” and that could only have been created on the iPad. The excitement and innova-
tion surrounding iOS and the sheer enjoyment of using the iOS devices has led it to become
the mobile platform of choice for users and developers alike.
With Apple, the user experience is key. The iOS is designed to be controlled with your fin-
gers rather than by using a stylus or keypad. The applications are “natural” and fun to use,
instead of looking and behaving like a clumsy port of a desktop app. Everything from inter-
face to application performance and battery life has been considered. The same cannot be
said for the competition.
Through the App Store, Apple has created the ultimate digital distribution system for devel-

opers. Programmers of any age or affiliation can submit their applications to the App Store
for just the cost of a modest yearly Developer Membership fee. Games, utilities, and full-
feature applications have been built for everything from pre-K education to retirement liv-
ing. No matter what the content, with a user base as large as the iPhone, iPod Touch, and
iPad, an audience exists.
Each year, Apple introduces new devices—bringing larger, faster, and higher-resolution
capabilities to the iOS family. With each new hardware refresh come new development
opportunities and new ways to explore the boundaries between software and art.
www.it-ebooks.info
My hope is that this book will bring iOS development to a new generation of developers.
Teach Yourself iOS 5 Development in 24 Hours provides a clear natural progression of skills
development, from installing developer tools and registering your device with Apple, to sub-
mitting an application to the App Store. It’s everything you need to get started in 24 one-
hour lessons.
Who Can Become an iOS Developer?
If you have an interest in learning, time to invest in exploring and practicing with Apple’s
developer tools, and an Intel Macintosh computer running Lion, you have everything you
need to begin creating software for iOS.
Developing an app won’t happen overnight, but with dedication and practice, you can be
writing your first applications in a matter of days. The more time you spend working with
the Apple developer tools, the more opportunities you’ll discover for creating new and excit-
ing projects.
You should approach iOS application development as creating software that you want to
use, not what you think others want. If you’re solely interested in getting rich quick, you’re
likely to be disappointed. (The App Store is a crowded marketplace—albeit one with a lot of
room—and competition for top sales is fierce.) However, if you focus on building apps that
are useful and unique, you’re much more likely to find an appreciative audience.
Who Should Use This Book?
This book targets individuals who are new to development for the iPhone and iPad and
have experience using the Macintosh platform. No previous experience with Objective-C,

Cocoa, or the Apple developer tools is required. Of course, if you do have development
experience, some of the tools and techniques may be easier to master, but the authors do
not assume that you’ve coded before.
That said, some things are expected of you, the reader. Specifically, you must be willing to
invest in the learning process. If you just read each hour’s lesson without working through
the tutorials, you will likely miss some fundamental concepts. In addition, you need to
spend time reading the Apple developer documentation and researching the topics pre-
sented in this book. There is a vast amount of information on iOS development available,
and only limited space in this book. This book covers what you need to forge your own
path forward.
2
Sams Teach Yourself iOS 5 Application Development in 24 Hours
www.it-ebooks.info
What Is (and Isn’t) in This Book?
The material in this book specifically targets iOS release 5 and later on Xcode 4.2 and later.
Much of what you’ll be learning is common to all the iOS releases, but this book also covers
several important areas that have only come about in iOS 4 and 5, such as gesture recog-
nizers, embedded video playback with AirPlay, Core Image, multitasking, universal
(iPhone/iPad) applications, and more!
Unfortunately, this is not a complete reference for the iOS APIs; some topics just require
much more space than this book allows. Thankfully, the Apple developer documentation is
available directly within the free tools you’ll be installing in Hour 1, “Preparing Your System
and iDevice for Development.” In many hours, you’ll find a section titled “Further
Exploration.” This identifies additional related topics of interest. Again, a willingness to
explore is an important quality in becoming a successful developer.
Each coding lesson is accompanied by project files that include everything you need to com-
pile and test an example or, preferably, follow along and build the application yourself. Be
sure to download the project files from the book’s website at . If
you have issues with any projects, view the posts on this site to see whether a solution has
been posted.

In addition to the support website, you can follow along on Twitter! Search for #iOSIn24 on
Twitter to receive official updates and tweets from other readers. Use the hashtag #iOSIn24
in your tweets to join the conversation. To send me messages via Twitter, begin each tweet
with @johnemeryray.
Introduction
3
www.it-ebooks.info
This page intentionally left blank
www.it-ebooks.info
HOUR 1
Preparing Your System and
iDevice for Development
What You’ll Learn in This Hour:
.
The iOS hardware limitations you face
.
Where to get the tools you need to develop for iOS devices
.
How to join the iOS Developer Program
.
The need for (and use of) provisioning profiles
.
What to expect during the first few hours of this book
The iOS device family opens up a whole realm of possibilities for developers: Multitouch
interfaces, always-on Internet access, video, and a whole range of built-in sensors can be
used to create everything from games to serious productivity applications. Believe it or
not, as a new developer, you have an advantage. You are starting fresh, free from any pre-
conceived notions of what is possible in a mobile application. Your next big idea may well
become the next big thing on Apple’s App Store.
This hour prepares you for your first development project. You’re about to embark on the

road to becoming an iOS developer, but you need to do a bit of prep work before you start
coding.
Welcome to the iOS Platform
If you’re reading this book, you probably already have an iOS device, and that means you
already understand how to interact with its interface. Crisp graphics, amazing responsive-
ness, multitouch, and hundreds of thousands of apps—this just begins to scratch the sur-
face. As a developer, however, you need to get accustomed to dealing with a platform
that, to borrow a phrase from Apple, forces you to “think different.”
www.it-ebooks.info
6
HOUR 1: Preparing Your System and iDevice for Development
iOS Devices
The iOS platform family currently consists of the iPhone, iPad, iPod Touch, and
Apple TV; but at present, the Apple TV is not open for development. As you work on
the tutorials in this book, you’ll notice that in many screenshots that I focus on
iPhone-centric projects. This isn’t because I’m lacking iPad love; it’s because iPad
interfaces are so large it’s difficult to capture them in a screenshot. The good news is
that if you want to develop a project on the iPad, you develop it on the iPad! If you
want to develop it for the iPhone, you develop it for the iPhone! In almost all cases,
the coding process is identical. In the few cases where it isn’t, I make sure you
understand what is different between the devices (and why). You’ll also find that
each tutorial is available in an iPad and iPhone version on this book’s website
(), so you can follow along with a working application
on whatever device you choose.
Like Apple’s developer tools and documentation, I do not differentiate between the
iPhone and iPod Touch in the lessons. For all intents and purposes, developing for
these devices is identical, although some capabilities aren’t available in earlier
versions of the iPod Touch (but the same can be said for earlier versions of the
iPhone and iPad, as well).
Display and Graphics

The iOS devices offer a variety of different resolutions, but iOS provides a simple way
of thinking about them. The iPhone screen, for example, is 320×480 points (see
Figure 1.1). Notice that I said points, not pixels. Prior to the release of the iPhone 4’s
Retina display, the iPhone was 320×480 pixels. Now, the actual resolution of an iOS
device is abstracted behind a scaling factor. This means that although you may be
working with the numbers 320×480 for positioning elements, you may have more
pixels than that. The iPhone 4 and 5, for example, have a scaling factor of 2, which
means that they are really (320×2) x (480×2) or 640×960 resolution devices.
Although that might seem like quite a bit of screen real estate, remember that all
these pixels are displayed on a screen that is roughly 3.5-inch diagonal.
The iPad 2, on the other hand, ships with a 1024×768 point screen. However, the
iPad 2 has a scaling factor of 1, so it is also a 1024×768 pixel screen. It is widely
expected that Apple will update the iPad with a Retina display in the next year, at
which time it will still have a 1024×768-point screen but a resolution of 2048×1536
pixels and a scaling factor of 2.
By the
Way
www.it-ebooks.info
Welcome to the iOS Platform
7
We take a closer look at how scaling factors work when we position objects on the
screen throughout this book. The important thing to know is that when you’re
building your applications, iOS automatically takes the scaling factor into play to
display your apps and their interfaces at the highest possible resolution (with
rarely any additional work on your part).
If you have a 27-inch cinema display on your desk, these handheld resolutions may
seem limiting. Keep in mind, however, that desktop computers only recently
exceeded this size, and many websites are still designed for 800×600. In addition, an
iOS device’s display is dedicated to the currently running application. You have one
window to work in. You can change the content within that window, but the desktop

and multiwindow application metaphors are gone.
The screen limits aren’t a bad thing. As you’ll learn, the iOS development tools give
you plenty of opportunities to create applications with just as much depth as your
desktop software—albeit with a more structured and efficient interface design.
The graphics that you display on your screen can include complex animated 2D and
3D displays thanks to the OpenGL ES implementation available on all iOS devices.
OpenGL is an industry standard for defining and manipulating graphic images that
320 Points
480 Points
FIGURE 1.1
The iPhone
screen is meas-
ured in points—
320×480
(portrait),
480×320 (land-
scape)—but
each point may
be made up of
more than 1
pixel.
Did You
Know?
www.it-ebooks.info
8
HOUR 1: Preparing Your System and iDevice for Development
is widely used when creating games. Each year’s device revisions improve these capa-
bilities with more advanced 3D chipsets and rendering abilities, but even the original
iPhone has very respectable imaging abilities.
Application Resource Constraints

As with the HD displays on our desktops and laptops, we’ve grown accustomed to
processors that can work faster than we can click. The iOS devices use a range of
processors, from a ~400MHz ARM in the early iPhones to a dual-core 1GHz A5 in the
iPad 2. The “A” chips are a “system on a chip” that provide CPU, GPU, and other
capabilities to the device, and this series is the first Apple-designed CPU series to be
used in quite awhile.
Apple has gone to great lengths to keep the iOS devices responsive regardless of what
you’re doing. Unfortunately, that means that unlike the Mac OS, your device’s capa-
bility to multitask is limited. Starting in iOS 4, Apple created a limited set of multi-
tasking APIs for very specific situations. These enable you to perform some tasks in
the background, but your application can never assume that it will remain running.
The iOS preserves the user experience above all else.
Another constraint that you need to be mindful of is the available memory. In the
original iPhone, 128MB of RAM is available for the entire system, including your appli-
cation. There is no virtual memory (slower storage space used as RAM), so you must
carefully manage the objects that your application creates. In the latest models of
the iPhone and iPad, Apple has graciously provided 512MB. This is great for us, but
keep in mind that there are no RAM upgrades for earlier models.
Connectivity
The iPhone and iPad 3G can always be connected to the Internet via a cellular
provider (such as AT&T or Verizon in the United States). This wide-area access is sup-
plemented with built-in WiFi and Bluetooth. WiFi can provide desktop-like browsing
speeds within the range of a wireless hot spot. Bluetooth, on the other hand, can be
used to connect a variety of peripheral devices to your device, including a keyboard.
As a developer, you can make use of the Internet connectivity to update the content
in your application, display web pages, and create multiplayer games. The only
drawback is that applications that rely heavily on 3G data usage stand a greater
chance of being rejected from the App Store. These restrictions have been lessened as
time goes by, but what is and isn’t permissible on a 3G network is still a point of
frustration among developers.

www.it-ebooks.info
Becoming an iOS Developer
9
Input and Feedback
iOS devices shine when it comes to input and feedback mechanisms and your ability
to work with them. You can read the input values from the capacitive multitouch
(up to 11 fingers on the iPad) screen, sense motion and tilt via the accelerometer
and gyroscope (iPhone 4, iPad 2, and later), determine where you are using the GPS
(3G required), see which way you’re facing with the digital compass (iPhone 4, iPad
2, and later), and understand how a device is being used with the proximity and
light sensors. iOS can provide so much data to your application about how and
where it is being used that the device itself truly becomes a controller of sorts—much
like (but surpassing) devices such as the Nintendo Wii and PlayStation Move.
iOS devices also support capturing pictures and video (iPhone, iPad 2, and later)
directly into your applications, opening a realm of possibilities for interacting with
the real world. Already applications are available that identify objects you’ve taken
pictures of and that find references to them online (such as the Amazon Mobile app)
or perform real-time translation of printed text (Word Lens).
Finally, for each action your user takes when interacting with your application, you
can provide feedback. This, obviously, can be visible feedback on the screen, or it
can be high-quality audio and force feedback via vibration (iPhone only). As a
developer, you can leverage all these capabilities (as you’ll learn in this book).
That wraps up our quick tour of the iOS platform. Never before has a single device
defined and provided so many capabilities for a developer. As long as you think
through the resource limitations and plan accordingly, a wealth of development
opportunities await you.
Becoming an iOS Developer
Being an iOS developer requires more than just sitting down and writing a program.
You need a modern Intel Macintosh desktop or laptop running Snow Leopard or
Lion and at least 6GB of free space on your hard drive. The more screen space you

have on your development system, the easier it is to create an effective workspace.
Lion users can even take Xcode into fullscreen mode, removing all distractions. That
said, I’ve worked perfectly happily on a 13-inch MacBook Air, so an ultra-HD multi-
monitor setup certainly isn’t necessary.
So assuming you already have a Mac, what else do you need? The good news is that
there isn’t much more, and it won’t cost you a cent to write your first application.
www.it-ebooks.info
10
HOUR 1: Preparing Your System and iDevice for Development
The standard program ($99) is available for both companies and individuals. If you
want to publish to the App Store with a business name, you are given the option
of choosing a standard “individual” or “company” program during the registration.
Registering as a Developer
Big or small, free or paid, your venture into iOS development begins on Apple’s web-
site. To start, visit the Apple iOS Dev Center ( shown
in Figure 1.2. If you have an existing Apple ID from using iTunes, iCloud, or other
Apple services, you can use that ID for your developer account. If not, or if you want
a new ID to use solely for development, you can create a new Apple ID during the
registration process.
Joining the Apple Developer Program
Despite somewhat confusing messages on the Apple website, there really is no fee
associated with joining the Apple Developer Program, downloading the iOS SDK
(Software Development Kit), writing iOS applications, and running them on Apple’s
iOS Simulator.
Limitations do apply, however, to what you can do for free. If you want to have
early access to beta versions of the iOS and SDK, you must be a paid member. If you
want to load the applications you write on a physical device or distribute them via
the App Store, you also need to pay the membership fee. Most applications in this
book work just fine on the simulator provided with the free tools, so the decision on
how to proceed is up to you.

Perhaps you aren’t yet sure whether the paid program is right for you. Don’t worry;
you can upgrade at any time. I recommend that you start with the free program
and upgrade after you’ve written a few sample applications and run them in the
simulator.
Obviously, things such as motion sensor input and GPS readings can’t be accu-
rately presented in the simulator, but these are special cases and aren’t needed
until later in this book.
If you choose to pay, the paid Developer Program offers two levels: a standard pro-
gram ($99) for those who will be creating applications that they want to distribute
from the App Store, and an enterprise program ($299) for large (500+ employee)
companies that want to develop and distribute applications in-house but not
through the App Store. Most likely, the standard program is what you want.
Did You
Know?
By the
Way
www.it-ebooks.info

×