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

490 beginning iOS 5 application development

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 (27.57 MB, 660 trang )

www.it-ebooks.info


www.it-ebooks.info
ffirs.indd i

05/12/11 3:01 PM


BEGINNING
IOS 5 APPLICATION DEVELOPMENT
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
CHAPTER 1

Getting Started with iOS 5 Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

CHAPTER 2

Writing Your First Hello World! Application . . . . . . . . . . . . . . . . . . . . . . . . .17

CHAPTER 3

Understanding Views, Outlets, and Actions . . . . . . . . . . . . . . . . . . . . . . . 35

CHAPTER 4

Exploring the Different View Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . 67

CHAPTER 5

Enabling Multi-Platform Support for the iPhone and iPad . . . . . . . . . . 109



CHAPTER 6

Handling Keyboard Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

CHAPTER 7

Supporting Screen Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

CHAPTER 8

Displaying and Persisting Data Using the Table View . . . . . . . . . . . . . 163

CHAPTER 9

Using Application Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

CHAPTER 10

File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

CHAPTER 11

Database Storage Using SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253

CHAPTER 12

Programming iCloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

CHAPTER 13


Performing Simple Animations and Video Playback . . . . . . . . . . . . . . . 295

CHAPTER 14

Accessing Built-In Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .317

CHAPTER 15

Accessing the Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339

CHAPTER 16

Using Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

CHAPTER 17

Bluetooth Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393

CHAPTER 18

Bonjour Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415

CHAPTER 19

Programming Remote Notifications Using Apple
Push Notification Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427

CHAPTER 20


Displaying Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449

CHAPTER 21

Programming Background Applications . . . . . . . . . . . . . . . . . . . . . . . . . 487

APPENDIX A

Testing on an Actual Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511

APPENDIX B

Getting Around in Xcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533

APPENDIX C

Crash Course in Objective-C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

APPENDIX D

Answers to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601

www.it-ebooks.info
ffirs.indd i

05/12/11 3:01 PM



www.it-ebooks.info
ffirs.indd ii

05/12/11 3:01 PM


BEGINNING

iOS 5 Application Development

www.it-ebooks.info
ffirs.indd iii

05/12/11 3:01 PM


www.it-ebooks.info
ffirs.indd iv

05/12/11 3:01 PM


BEGINNING

iOS 5 Application Development
Wei-Meng Lee

John Wiley & Sons, Inc.

www.it-ebooks.info

ffirs.indd v

05/12/11 3:01 PM


Beginning iOS 5 Application Development
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256

www.wiley.com
Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-14425-1
ISBN: 978-1-118-22571-4 (ebk)
ISBN: 978-1-118-23584-3 (ebk)
ISBN: 978-1-118-26369-3 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
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, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011,
fax (201) 748-6008, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work

is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Neither
the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or
the publisher endorses the information the organization or Web site may provide or recommendations it may make.
Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between
when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats and by print-on-demand. Not all content that is available
in standard print versions of this book may appear or be packaged in all book formats. If you have purchased a version
of this book that did not include media that is referenced by or accompanies a standard print version, you may request
this media by visiting . For more information about Wiley products, visit us at
www.wiley.com.
Library of Congress Control Number: 2011944672
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. All other trademarks are the property of their respective
owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.

www.it-ebooks.info
ffirs.indd vi

05/12/11 3:01 PM


Dedicated to Steve Jobs, whose vision changed the
way we use computers and inspires many to follow his
footsteps. Thank you for the inspiration!


www.it-ebooks.info
ffirs.indd vii

05/12/11 3:01 PM


www.it-ebooks.info
ffirs.indd viii

05/12/11 3:01 PM


ABOUT THE AUTHOR

WEI-MENG LEE is a technologist and founder of Developer Learning Solutions (www
.learn2develop.net), a technology company specializing in hands-on training on

the latest mobile technologies. Wei-Meng has many years of training experience and
his training courses place special emphasis on the learning-by-doing approach. His
hands-on approach to learning programming makes understanding the subject much
easier than reading books, tutorials, and documentation. His name regularly appears in
online and print publications such as DevX.com, MobiForge.com, and CoDe Magazine.
Wei-Meng Lee is frequently invited to speak at technological conferences, and recently participated
in Mobile Connections in the United States and DevTeach/DevMobile in Montreal, Canada.
Contact Wei-Meng at

ABOUT THE TECHNICAL EDITOR

TRENT SHUMAY is the founder and Chief Architect at Finger Food Studios, Inc., in the Vancouver,
BC, area. After graduating from the UBC Computer Science program, Trent spent 13 years in the

gaming and interactive entertainment space, where handheld gaming devices ignited his passion
for mobile development. Today, Finger Food Studios focuses on developing media-rich, interactive
mobile and web applications. You can reach Trent directly at

www.it-ebooks.info
ffirs.indd ix

05/12/11 3:01 PM


www.it-ebooks.info
ffirs.indd x

05/12/11 3:01 PM


CREDITS

EXECUTIVE EDITOR

PRODUCTION MANAGER

Robert Elliott

Tim Tate

SENIOR PROJECT EDITOR

VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER


Ami Frank Sullivan

Richard Swadley
TECHNICAL EDITOR

Trenton Shumay

VICE PRESIDENT AND EXECUTIVE
PUBLISHER

PRODUCTION EDITOR

Neil Edde

Kathleen Wisor
ASSOCIATE PUBLISHER
COPY EDITOR

Jim Minatel

Luann Rouff
PROJECT COORDINATOR, COVER
EDITORIAL MANAGER

Katie Crocker

Mary Beth Wakefield
FREELANCER EDITORIAL MANAGER


Rosemarie Graham
ASSOCIATE DIRECTOR OF MARKETING

David Mayhew

PROOFREADER

Nancy Carrasco
INDEXER

Robert Swanson

MARKETING MANAGER

COVER DESIGNER

Ashley Zurcher

Ryan Sneed

BUSINESS MANAGER

COVER IMAGE

Amy Knies

© -M-I-S-H-A- /iStockPhoto

www.it-ebooks.info
ffirs.indd xi


05/12/11 3:01 PM


www.it-ebooks.info
ffirs.indd xii

05/12/11 3:01 PM


ACKNOWLEDGMENTS

OVER THE PAST YEAR OR SO, the development landscape of Apple’s iOS has changed greatly.
The successful iOS is now in its fifth iteration, and the Xcode IDE has transitioned to a much
easier-to-use version 4, with a tight integration of Interface Builder. I have received a lot of
feedback from readers of the previous edition of this book, many of whom appreciate the hands-on
approach that it takes. I also have received feedback from readers who are stumped by the changes
that have occurred between Xcode versions 3 and 4; but such confusion epitomizes the rapid pace of
change that all developers experience.

This new edition of the book was revised to cover both new technologies and the various feedback
I have received. I had a thorough relook at the exercises readers were having issues with, to ensure
that they can be easily followed and achieve the effect I intended. I also took this opportunity to
revise all the examples using Xcode 4, which is the IDE included with iOS 5. Of course, this book
covers new iOS 5 features — notably, the new iCloud feature that ships with iOS 5. I have also
added some topics that would interest most iOS developers, such as how to import and export
documents from within your application, programming the various sensors in iOS, and using JSON
web services.
Writing a book is always exciting, but along with the excitement are long hours of hard work,
straining to get things done accurately and on time. I would like to take this opportunity to thank a

number of people who helped to make this book possible.
First, I want to thank my Executive Editor Robert Elliott, who started off as a stranger, but is now
my good friend. Robert is not the usual AE, disappearing after the contract is signed. He has been
involved throughout the entire writing process and is always ready to help. I can’t say enough good
things about Robert, so I will just say thank you, Robert!
Next, a huge thanks to Ami Sullivan, my project editor, who is always a pleasure to work with. Ami
is the force behind the scenes, who makes the book appear on time on shelves in the bookstores!
Thanks, Ami!
I also thank copy editor Luann Rouff and technical editor Trenton Shumay. They have been eagleeye editing the book, ensuring that every sentence makes sense — both grammatically as well as
technically. Thanks, Luann and Trent!
Last, but not least, I want to thank my parents, and my wife, Sze Wa, for all the support they have
given me. They have selflessly adjusted their schedules to accommodate my busy schedule when
I was working on this book. My wife, as always, has stayed up with me on numerous nights as I
furiously worked to meet a deadline, and for this I would like to say to her and my parents: “I love
you all!” Finally, to our lovely dog, Ookii, thanks for staying by our side. Now that the book is
done, sorry . . . daddy needs to write another book. . .

www.it-ebooks.info
ffirs.indd xiii

05/12/11 3:01 PM


www.it-ebooks.info
ffirs.indd xiv

05/12/11 3:01 PM


CONTENTS


INTRODUCTION

xxi

CHAPTER 1: GETTING STARTED WITH IOS 5 PROGRAMMING

Obtaining the Tools and SDK
Components of Xcode
Xcode
iOS Simulator
Interface Builder
Instruments

1

2
3
3
4
9
10

Architecture of the iOS
Some Useful Information before You Get Started
Versions of iOS
Testing on Real Devices
Screen Resolutions

11

13
13
14
14

Summary

15

CHAPTER 2: WRITING YOUR FIRST HELLO WORLD! APPLICATION

Getting Started with Xcode

17

17

Using Interface Builder
Writing Some Code

20
24

Customizing Your Application Icon
Displaying Launch Images
Summary
CHAPTER 3: UNDERSTANDING VIEWS, OUTLETS, AND ACTIONS

Outlets and Actions
Using Views


26
28
33
35

36
40

Using the Alert View
Using the Action Sheet
Page Control and Image View
Using the Web View

Adding Views Dynamically Using Code
Understanding View Hierarchy
Summary

41
45
46
55

57
61
62

www.it-ebooks.info
ftoc.indd xv


05/12/11 3:01 PM


CONTENTS

CHAPTER 4: EXPLORING THE DIFFERENT VIEW CONTROLLERS

The Single View Application Template
Application Delegate
Controlling Your UI Using View Controllers

The Empty Application Template
Adding a View Controller and Views Programmatically
Animating the Switching of Views

The Master-Detail Application Template
Displaying Some Items in the Master-Detail Application

The Tabbed Application Template
Summary

67

68
71
74

77
81
87


89
98

103
107

CHAPTER 5: ENABLING MULTI-PLATFORM SUPPORT
FOR THE IPHONE AND IPAD

109

Technique 1 — Modifying the Device Target Setting

109

Detecting the Platform Programmatically

Technique 2 — Creating Universal Applications
Choosing a Porting Technique
Summary
CHAPTER 6: HANDLING KEYBOARD INPUTS

Using the Keyboard
Customizing the Type of Inputs
Dismissing the Keyboard
Automatically Displaying the Keyboard When
the View Window Is Loaded

Detecting the Presence of the Keyboard

Using the Scroll View
Scrolling Views When the Keyboard Appears

Summary

114

116
120
120
123

124
125
127
133

133
134
138

145

CHAPTER 7: SUPPORTING SCREEN ROTATIONS

Responding to Device Rotations
Rotating to a Different Screen Orientation
Handling Rotations

Programmatically Rotating the Screen

Rotating during Runtime
Fixing the View Window to a Specific Orientation

Summary

149

149
152
153

159
159
159

160

xvi

www.it-ebooks.info
ftoc.indd xvi

05/12/11 3:01 PM


CONTENTS

CHAPTER 8: CREATING AND PERSISTING DATA USING
THE TABLE VIEW


Creating a Simple Table View
Adding a Header and Footer
Adding an Image
Displaying the Item Selected
Indenting
Modifying the Height of Each Row

Using the Table View in a Master-Detail Application
Displaying Sections
Adding Indexing
Adding Search Capability
Disclosures and Checkmarks
Navigating to Another View

Summary

163

164
169
169
171
173
173

173
174
183
183
194

195

199

CHAPTER 9: USING APPLICATION PREFERENCES

201

Creating Application Preferences
Programmatically Accessing the Settings Values

202
209

Loading the Settings Values
Resetting the Preferences Settings Values
Saving the Settings Values

Summary

214
216
217

218

CHAPTER 10: FILE HANDLING

221


Understanding the Application Folders
Using the Documents and Library Folders
Storing Files in the Temporary Folder
Which Folder Should You Use: Documents or tmp?

Using Property Lists
Copying Bundled Resources
Importing and Exporting Files
Exporting Documents
File Sharing
Importing Documents
Importing Self-Defined Documents

Summary

222
223
227
228

228
235
237
239
242
245
248

251


xvii

www.it-ebooks.info
ftoc.indd xvii

05/12/11 3:01 PM


CONTENTS

CHAPTER 11: DATABASE STORAGE USING SQLITE

253

Linking to the SQLite3 Library
Creating and Opening a Database

254
256

Examining the Database Created
Creating a Table
Inserting Records
Bind Variables
Retrieving Records

258
258
259
260

263

Bundling SQLite Databases with Your Application
Summary
CHAPTER 12: PROGRAMMING ICLOUD

Storing and Using Documents in iCloud
Enabling iCloud Storage for Your Application
Setting Project Entitlements
Managing iCloud Documents Using the UIDocument Class
Storing Documents on iCloud

Storing Key-Value Data in iCloud
Summary
CHAPTER 13: PERFORMING SIMPLE ANIMATIONS AND
VIDEO PLAYBACK

Using the NSTimer Class

265
266
269

270
270
273
276
278

289

292
295

295

Animating the Visual Change

Transforming Views

302

302

Translation
Rotation
Scaling

303
305
307

Animating a Series of Images
Playing Video on the iPhone
Summary
CHAPTER 14: ACCESSING BUILT-IN APPLICATIONS

Sending E-Mail

307
310

314
317

317

Invoking Safari
Invoking the Phone
Invoking SMS

324
324
324

xviii

www.it-ebooks.info
ftoc.indd xviii

05/12/11 3:01 PM


CONTENTS

Accessing the Camera and the Photo Library
Accessing the Photo Library
Accessing the Camera

327
327
332


Summary

335

CHAPTER 15: ACCESSING THE SENSORS

Using the Gyroscope and Accelerometer
Visualizing the Sensor Data
Using the Shake API to Detect Shakes
Summary
CHAPTER 16: USING WEB SERVICES

Basics of Consuming XML Web Services
Using SOAP 1.1
Using SOAP 1.2
Using HTTP POST

339

339
345
350
356
359

360
361
363
364


Consuming a Web Service in Your iOS Application Using SOAP
Parsing the XML Response
Consuming JSON Web Services
Integrating Twitter into Your Application
Summary
CHAPTER 17: BLUETOOTH PROGRAMMING

365
373
377
383
389
393

Using the Game Kit Framework

393

Searching for Peer Devices
Sending and Receiving Data

394
401

Implementing Voice Chatting
Summary

404
412


CHAPTER 18: BONJOUR PROGRAMMING

Creating the Application
Publishing a Service
Browsing for Services
Summary

415

415
417
420
425

CHAPTER 19: PROGRAMMING REMOTE NOTIFICATIONS USING
APPLE PUSH NOTIFICATION SERVICES

427

Using Apple Push Notification Service

428

Generating a Certificate Request
Generating a Development Certificate

428
429
xix


www.it-ebooks.info
ftoc.indd xix

05/12/11 3:01 PM


CONTENTS

Creating an Application ID
Configuring an App ID for Push Notifications
Creating a Provisioning Profile
Provisioning a Device

Creating the iOS Application
Creating the Push Notification Provider
Summary
CHAPTER 20: DISPLAYING MAPS

Displaying Maps and Monitoring Changes Using the Map Kit
Getting Location Data
Specifying the Hardware Requirement for Location Tracking
Displaying Location Using a Map
Getting Directional Information
Rotating the Map
Displaying Annotations
Reverse Geocoding
Displaying a Disclosure Button

Summary


431
433
435
437

438
443
447
449

449
455
460
460
464
468
474
478
482

484

CHAPTER 21: PROGRAMMING BACKGROUND APPLICATIONS

487

Understanding Background Execution on the iOS

488


Examining the Different Application States
Opting Out of Background Mode
Detecting Multitasking Support
Tracking Locations in the Background
Making Your Location Apps More Energy Efficient

488
491
492
492
496

Local Notification
Notifying Other Objects Using the NSNotification Class
Summary
APPENDIX A: TESTING ON AN ACTUAL DEVICE

498
505
509
511

APPENDIX B: GETTING AROUND IN XCODE

533

APPENDIX C: CRASH COURSE IN OBJECTIVE-C

559


APPENDIX D: ANSWERS TO EXERCISES

587

INDEX

601

xx

www.it-ebooks.info
ftoc.indd xx

05/12/11 3:01 PM


INTRODUCTION

APPLE FIRST OFFICIALLY ANNOUNCED the iOS 5 at the Worldwide Developers Conference (WWDC)
in June 2011. After 7 betas and with much anticipation, Apple finally rolled out iOS 5 with the
vastly improved iPhone 4S. With 200 new features added to the iOS, Apple is set to reign as the
king of the mobile platform for the foreseeable future. This means developers also have vast
potential for their applications — if you know how to program for the iOS platform. This book
will show you how.

When I first started learning about iPhone and iPad development, I went through the same journey
that most developers go through: Write a Hello World application, play around with Xcode and
Interface Builder, try to understand what the code is doing, and repeat that process. I was also
overwhelmed by the concept of a View Controller, and wondered why it was needed if I simply

wanted to display a view. My background in developing for Windows Mobile and Android did not
help much, and I had to start working with this concept from scratch.
This book was written to help jump-start beginning iPhone and iPad developers. It covers the
various topics in a linear manner that enables you to progressively learn without being overwhelmed
by the details. I adopt the philosophy that the best way to learn is by doing — hence, the numerous
hands-on “Try It Out” sections in each chapter, which first demonstrate how to build something
and then explain “How It Works.”
Although iPhone and iPad programming is a huge topic, my aim in this book is to get you started
with the fundamentals, help you understand the underlying architecture of the SDK, and appreciate
why things are done in a certain way. It is beyond the scope of any one book to cover everything
under the sun related to iPhone and iPad programming, but I am confident that after reading
this book (and doing the exercises), you will be well equipped to tackle your next iPhone or iPad
programming challenge.

WHO THIS BOOK IS FOR
This book is for the beginning iPhone and iPad developer who wants to start developing
applications using the Apple iOS SDK. To truly benefit from this book, you should have some
background in programming and at least be familiar with object-oriented programming concepts.
If you are totally new to the Objective-C language, you might want to jump straight to Appendix
C, which provides an overview of the language. Alternatively, you can use Appendix C as a quick
reference while you tackle the various chapters, checking out the syntax as you try the exercises.
Depending on your learning style, one of these approaches should work best for you.
While most of the chapters are geared toward developing for the iPhone, the concepts apply to
iPad development as well. In cases where specific features are available only on the iPad, they are
pointed out.

www.it-ebooks.info
flast.indd xxi

05/12/11 3:02 PM



INTRODUCTION

NOTE All the examples discussed in this book were written and tested using
the iOS SDK 5.0. While every effort has been made to ensure that the screen
shots are as current as possible, the actual screen that you see may differ when
the iOS SDK is revised.

WHAT THIS BOOK COVERS
This book covers the fundamentals of iPhone and iPad programming using the iOS SDK. It is
divided into 21 chapters and four appendices.
Chapter 1: Getting Started with iOS 5 Programming covers the various tools found in the iOS SDK
and explains their uses in iPhone and iPad development.
Chapter 2: Write Your First Hello World! Application gets you started with Xcode and Interface
Builder to build a Hello World application. The focus is on giving you some hands-on practice
getting a project up and running quickly. More details on the various project components are
covered in subsequent chapters.
Chapter 3: Understanding Views, Outlets, and Actions covers the fundamental concepts of iPhone
and iPad programming: outlets and actions. You learn how outlets and actions allow your code
to interact with the visual elements in Interface Builder and why they are an integral part of every
iPhone and iPad application. You will also learn about the various UI widgets known as views that
make up the user interface of your application.
Chapter 4: Exploring the Different View Controllers discusses the various View Controllers
available in the iOS SDK. You will learn how to develop different types of applications — Single
View, Master-Detail, as well as Tabbed applications.
Chapter 5: Enabling Multi-Platform Support for the iPhone and iPad shows how you can port your
iPhone applications to the iPad platform. You will also learn how to create universal applications
that will run on both the iPhone and the iPad.
Chapter 6: Handling Keyboard Inputs shows you how to deal with the virtual keyboard in your

iPhone or iPad. You learn how to hide the keyboard on demand and how to ensure that your views
are not blocked by the keyboard when it is displayed.
Chapter 7: Supporting Screen Rotations demonstrates how you can reorient your application’s UI
when the device is rotated. You learn about the various events that are fired when the device is
rotated, and how to force your application to be displayed in a certain orientation.
Chapter 8: Displaying and Persisting Data Using the Table View explores one of the most
powerful views in the iOS SDK — the Table View. The Table View is commonly used to display
rows of data. In this chapter, you also learn how to implement search capabilities in your
Table View.

xxii

www.it-ebooks.info
flast.indd xxii

05/12/11 3:02 PM


INTRODUCTION

Chapter 9: Using Application Preferences discusses the use of application settings to persist application
preferences. Using application settings, you can access preferences related to your application through
the Settings application available on the iPhone and iPad.
Chapter 10: File Handling shows how you can persist your application data by saving the data
to files in your application’s sandbox directory. You also learn how to access the various folders
available in your application sandbox.
Chapter 11: Database Storage Using SQLite covers the use of the embedded SQLite3 database
library to store your data.
Chapter 12: Programming iCloud discusses and demonstrates how to store your documents and
application-specific data on Apple’s new iCloud feature.

Chapter 13: Performing Simple Animations and Video Playback provides an overview of the various
techniques you can use to implement basic animations on the iPhone and iPad. You also learn about
the various affine transformations supported by the iOS SDK. In addition, you learn how to play
back video on the iPhone and iPad.
Chapter 14: Accessing Built-In Applications describes the various ways you can access the iPhone
and iPad’s built-in applications, such as the Photo Library, Contacts, and others. You also learn how
you can invoke built-in applications such as Mail and Safari from within your applications.
Chapter 15: Accessing the Sensors shows how you can access the accelerometer and gyroscope
sensors that are included with every iPhone and iPad. You will also learn how to detect shakes to
your device.
Chapter 16: Using Web Services teaches you how to consume web services from within your iPhone
and iPad application. You will learn the various ways to communicate with four web services —
JSON, SOAP, HTTP GET, and HTTP POST. You will also learn how to parse the XML result
returned by the web service.
Chapter 17: Bluetooth Programming explores the use of the Game Kit framework for Bluetooth
programming. You will learn how to enable two devices to communicate using a Bluetooth
connection, and how to implement voice chatting over a Bluetooth connection.
Chapter 18: Bonjour Programming shows how you can publish and find services on the network
using the Bonjour protocol.
Chapter 19: Programming Remote Notifications Using Apple Push Notification Services
explains how you can implement applications that use push notifications. The APNs enables
your applications to continuously receive status updates from a service provider even though the
application may not be running.
Chapter 20: Displaying Maps demonstrates how to build a location-based services application using
the Map Kit framework. You will also learn how to obtain geographical location data and use it to
display a map.
Chapter 21: Programming Background Applications shows how to build applications that can
continue to run in the background when the user switches to another application. You will also
xxiii


www.it-ebooks.info
flast.indd xxiii

05/12/11 3:02 PM


×