This is not the document you are looking for? Use the search form below to find more!

Report home > Gadget

iPad Programming: A Quick-Start Guide for iPhone Developers

0.00 (0 votes)
Document Description
Throughout this book, we show you how to build experiences for this new device. We'll explore the similarities and differences be tween developing for the iPad and what you're used to in developing for the iPhone. In fact, we'll start by creating an iPhone app in this chapter and transform it into an app that runs on your iPad.
File Details
Submitter
  • Name: bela
Embed Code:

Add New Comment




Related Documents

Microcat Daihatsu Parts Quick Start Guide

by: manualzon, 26 pages

ebook about guide on Microcat Quick Start Guide for daihatsu selling parts

A Quick-Start Guide To Acupuncture

by: richard323lauritsen, 2 pages

In chinese medicine , practitioners adhere to the concept of chi , or energy flow, and also the

The Best Way To Get Abs -- Quick Start Guide For Men To Get Ripped Abs

by: harold9232griggs, 2 pages

Begin by sitting in the ground , now bring your feet started , around 6 inches as well as hold them in

Samsung Step By Step Guide for iPhone

by: csenger, 0 pages

Samsung Step By Step Guide for iPhone. Samsung Mobile DataGate

MOTOROLA ROADSTER™ Quick Start Guide

by: patrick, 108 pages

MOTOROLA ROADSTER™ Quick Start Guide

testo 550 Quick Start Guide

by: Shiv, 2 pages

Quick Start Guide

Oracle Enterprise Repository 11g - Quick Start Guide

by: joline, 6612 pages

Oracle Enterprise Repository 11g Quick Start Guide Sreeni Setty http://www.linkedin.com/in/sreenisetty INTRODUCTION ...

NVIDIA Control Panel Quick Start Guide

by: titina, 34 pages

This quick start is addressed to users of the NVIDIA® Control Panel software. This guide focuses on getting you up and running with your NVIDIA software. For technical details on the features ...

KeyRig 49 Quick Start Guide

by: rockfordfile, 6 pages

User Guide for keyboard

iPhone User’s Guide: for iPhone and iPhone 3G

by: manualzon, 130 pages

gadget service manual/repair manual/user guide/owners guide and many more, in this post we covers free iphone and iphone 3g user manual from apple

Content Preview
Extracted from:
iPad Programming
A Quick-Start Guide for iPhone Developers
This PDF file contains pages extracted from iPad Programming, published by the
Pragmatic Bookshelf. For more information or to purchase a paperback or PDF copy,
please visit http://www.pragprog.com.
Note: This extract contains some colored text (particularly in code listing). This is
available only in online versions of the books. The printed versions are black and white.
Pagination might vary between the online and printer versions; the content is otherwise
identical.
Copyright © 2010 The Pragmatic Programmers, LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any
means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher.


Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts are claimed as trademarks. Where those designations appear in this book, and The
Pragmatic Programmers, LLC was aware of a trademark claim, the designations have
been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The
Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g
device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher
assumes no responsibility for errors or omissions, or for damages that may result from
the use of information (including program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help you and your team
create better software and have more fun. For more information, as well as the latest
Pragmatic titles, please visit us at
http://www.pragprog.com
Copyright © 2010 Pragmatic Programmers, LLC.
All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmit-
ted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher.
Printed in the United States of America.
ISBN-10: 1-934356-57-3
ISBN-13: 978-1-934356-57-9
Printed on acid-free paper.
B1.0 printing, April 3, 2010
Version: 2010-4-14

Chapter 1
From iPhone to iPad
Before you write a line of code for your iPad app, you need to hold the
device in your hands. You need to feel the device melt away as you
become immersed in an app. The app you are using gets out of your
way as you get involved in an activity it enables.
That’s the kind of app we want you to write.
We don’t merely want you to write apps that run on an iPad, we want
you to write apps that are perfect for the platform. People are going to
tell their friends about your app because it delights them when they
notice it, and it disappears as they use it.
How can that be? Isn’t the iPad just an oversized iPod touch that runs
on the same iPhone OS we already know and love? Have we become
caught up in the marketing hype generated by Steve Jobs’ famous real-
ity distortion field?
No. There is something fundamentally different about this high resolu-
tion device with its large display that fits in your hands but not your
pocket—a device that you navigate with multi-touch and gestures.
Throughout this book, we show you how to build experiences for this
new device. We’ll explore the similarities and differences between devel-
oping for the iPad and what you’re used to in developing for the iPhone.
In fact, we’ll start by creating an iPhone app in this chapter and trans-
form it into an app that runs on your iPad.
But first let’s figure out how the iPad fits in your end users’ lives—
somewhere between the laptop and the iPhone.

THE IPAD AND THE LAPTOP
12
1.1
The iPad and the Laptop
Once you’ve checked email or surfed the web on an iPad, your laptop is
going to seem bulkier and less portable than it was the minute before
you picked up the iPad. Suddenly, you’ll be aware of the amount of
space required to house the keyboard, trackpad, hard drive, and bat-
tery.
On the other hand, your iPad is more constrained. It is not meant to
live as a standalone device. It must be synced to a laptop or desktop
machine once in a while. It doesn’t have the processing power, memory,
or storage of a laptop. It is designed to belong to a single user, with a
single app occupying your attention at any given time. The iPad is not
meant to be the digital hub that a desktop or laptop becomes. For now,
it is a node on the hub, not the center of your digital universe.
Most importantly, there is something very different about interacting
with the screen by touching it as opposed to having to use a mouse or a
trackpad. On the iPad, you use your finger to land planes in Flight Con-
trol, paint beautiful images with Brushes, and mark email messages as
deleted. If you want to move or guide an object, you put your finger on
it and move your finger. The object comes along for the ride.
If you want to resize an object, you use two fingers to pinch or zoom.
You use your finger to resize, reposition, and crop an image. You zoom
in on a web page to better read it, and so that your finger can more
easily select the right text box to type into. These gestures have become
so natural that it feels strange to use a mouse to select an object and
grab handles to resize and reposition. Reaching for the mouse or the
trackpad takes us out of the moment.
The last important difference between an iPad and a laptop is that you
can easily rotate the iPad ninety degrees and get a whole different view
of your application. In fact, as an iPad developer, you are asked to con-
sider how best to present your app in both landscape and portrait ori-
entations.
1.2
The iPad and the iPod Touch
The iPad runs iPhone OS. You will use many of the same APIs to write
your iPad apps that you use to write apps for the iPhone. So isn’t the
iPad just a big iPod touch?
CLICK HERE to purchase this book now.

THE IPAD AND THE IPOD TOUCH
13
It’s certainly true that an iPad is much bigger than an iPhone. An iPad
is about the size of the printed version of this book—about half an
inch taller and a little thinner, but roughly the same size. The iPhone
is much smaller. Here’s a picture that shows the relative size of two
iPhone screens to the iPad screen.
So the iPad is a big iPod touch—it’s just not just a big iPod touch. Being
bigger is the key to what makes it special.
Much of the GUI that you know and love on Mac OS X and later on
Windows originated at Xerox PARC with Alan Kay’s team. Kay has con-
sistently complained that the way we interact with a computer has not
changed enough from the work his team was doing decades ago. Alan
Kay told Gigaom’s Janko Roettgers this story about Kay’s reaction to
the unveiling of the iPhone in 2007.
“When the Mac first came out, Newsweek asked me what I [thought]
of it. I said: Well, it’s the first personal computer worth criticizing. So
at the end of the presentation, Steve came up to me and said: Is the
CLICK HERE to purchase this book now.

GETTING STAR TED
14
iPhone worth criticizing? And I said: Make the screen five inches by
eight inches, and you’ll rule the world.”1
The size is an important part of the story. On the iPad, you can browse
web pages at full resolution, sort your pictures into piles with a flick of
your finger, and fill out forms using a keyboard you can fit all of your
fingers on.
You will be missing the point if you think of the iPad from the devel-
oper’s point of view. The APIs are similar enough to those for the iPhone
that apps for one device can easily be run on the other. When you start
to create an app for the iPad, take the time to understand what is dif-
ferent and special about this device.
Your favorite iPhone apps are the ones that take advantage of all of
the capabilities of the iPhone in natural ways.2 They incorporate the
accelerometer, the compass, the GPS, the camera, and the phone itself
when it makes sense. In the remainder of the book we will show you
how to program the iPad, but it’s up to you to think about what to
program.
1.3
Getting Started
In this book, we assume you know how to develop iPhone apps. Maybe
you’ve written an iPhone app or two for fun or profit. You are certainly
familiar with Cocoa, Objective-C, and the iPhone APIs. You are com-
fortable with the most recent versions of Xcode and Interface Builder.
You know how to work with view controllers and delegates and can use
reference counting to manage memory.
So that’s where we’ll start.
We’ll create an iPhone app and quickly review some of the key con-
cepts you’ll need to know in this book. These techniques are common
to iPhone and iPad development. You’ll see this at the end of the chap-
ter when we convert this from a project that only works on the iPhone
to one that works on both the iPhone and the iPad.
By the end of this chapter, you’ll know whether you have the right
amount of background for this book. Everything should be familiar,
1.
http://gigaom.com/2010/01/26/alan-kay-with-the-tablet-apple-will-rule-the-world/
2.
It will get tedious to say “iPhone and iPod touch” every time. We’ll often use one or the
other to refer to the common platform.
CLICK HERE to purchase this book now.

GETTING STAR TED
15
What You Need for This Book
You wil need to register as an iPhone developer for free at
http://developer.apple.com/iphone. There is an additional yearly
charge (currently $99) if you want to deploy your applications
to your iPad or iPhone or sel your applications on the iTunes
App Store.
Once you’ve registered, download the latest tools and SDKs.
Currently, iPad development requires that you are running Mac
OS X 10.6.2 on an Intel machine. The examples in this book were
created using Xcode version 3.2.2 and iPhone OS 3.2.
Also, you can download all of the projects for this book from the
book’s homepage at http://pragprog.com/titles/sfipad.
and the quick review should be enough to bring you up to speed for the
remainder of the book. If you find yourself confused or think that we’re
moving too fast, then you may need to start with a book on Cocoa or
iPhone development.3
If you think we’re moving too slowly and you want to get right to the
iPad material, start with the project in the FromTo/DailyShoot1 directory
in the code download, and skip ahead to Section 1.8, Creating an iPad
Version.
We’ll build a simple navigation-based application around “The Daily
Shoot” (http://dailyshoot.com) website created by Mike Clark and James
Duncan Davidson. Their site has suggested a daily assignment for pho-
tographers since November 2009. In this type of app, users navigate
through some number of levels of table views until they select an indi-
vidual item and navigate to its detail view.
Our app will launch with a simple table that is filled with the numbers
of the first 125 assignments. When a user selects a number, we will
display the landing page for that assignment.
3.
You can start with Cocoa Programming: A Quick-Start Guide for Developers [Ste09]
and/or iPhone SDK Development [DA09].
CLICK HERE to purchase this book now.

GETTING STAR TED
16
There’s nothing fancy about this example, but it lets us set up all of the
machinery we need for a nav-based application, and it sets the stage
for the Split View-based application in the next chapter.
Start up Xcode and create a new Navigation-based Application that
does not use Core Data for storage. Name the project “DailyShoot”.
By the way, you may have noticed some important differences in the
templates you had available. The Split View-based template is brand
new, and can only be used for iPad-based projects. The Navigation-
based Application and Utility Application templates can only be used for
new iPhone projects. The Window-based template can create an iPhone
project, an iPad project, or a Universal project that targets both plat-
forms at once. The remaining templates can be used as the starting
point for either iPhone or iPad projects, but you have to specify which
using a drop-down.
We’re not going to do anything with the app delegate or with the Main-
Window nib. If this were a production app, we would take the time to
change the name of the RootViewControl er class and the correspond-
ing nib to something that has more meaning in the current setting—
CLICK HERE to purchase this book now.

ADDING A MODEL OBJECT
17
something like AssignmentViewControl er. Because it’s easy to make an
error making these changes and because the changes have nothing to
do with what we’re working on in this chapter, we’ll leave the names as
they are.
1.4
Adding a Model Object
A table view needs a data source that can answer three basic questions:
• How many sections are in the table?
• For each section, how many rows are in this section?
• For each row, what goes in this row?
In the project created for us from the template, the RootViewControl er is
the table view’s data source. We’re going to add a model object to our
project. This is the classic MVC (Model View Controller) decoupling. The
view talks to the controller and the controller talks to the model.
tableView:
numberOfRowsInSection:
count:
UITableView
RootViewController
Assignments
The table view sends the message tableView:numberOfRowsInSection: to
the controller. The controller in turn sends the message count to the
Assignments object, our model object. The model object responds to the
controller with the number of assignments, which the controller then
relays on to the table view so that it knows how many rows will be
displayed.
To implement this, in Xcode add a new Objective-C class that is a sub-
class of NSObject and name it Assignments.
An Assignments object will need to let the controller know how many
total assignments there are and be able to tell the controller which
assignment number goes in a given row. It will keep the collection of
assignments internally in an NSArray named assignmentArray. This is all
captured in the header file.
Download FromTo/DailyShoot1/Classes/Assignments.h
#import <Foundation/Foundation.h>
CLICK HERE to purchase this book now.

Download
iPad Programming: A Quick-Start Guide for iPhone Developers

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share iPad Programming: A Quick-Start Guide for iPhone Developers to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share iPad Programming: A Quick-Start Guide for iPhone Developers as:

From:

To:

Share iPad Programming: A Quick-Start Guide for iPhone Developers.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share iPad Programming: A Quick-Start Guide for iPhone Developers as:

Copy html code above and paste to your web page.

loading