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

iPhone and ipad app 24 hour trainer

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.25 MB, 589 trang )

www.it-ebooks.info


www.it-ebooks.info


iPhone® and iPad® App
24-Hour Trainer
Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
LESSON 1

Hello iOS!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

LESSON 2

The iOS Simulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

LESSON 3

A Tour of Xcode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

LESSON 4

iOS Application Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

LESSON 5

Introduction to Storyboards. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

LESSON 6


Handling User Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

LESSON 7

Communicating with Your Users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

LESSON 8

Adding Images to Your View. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

LESSON 9

Pickers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

LESSON 10

Date Pickers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

LESSON 11

Custom Pickers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

LESSON 12

Navigation Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

LESSON 13

Table Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147


LESSON 14

Static Table Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

LESSON 15

Tab Bars and Toolbars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

LESSON 16

Creating Page-Based Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

LESSON 17

Creating UI Elements Programmatically . . . . . . . . . . . . . . . . . . . . . . . . . . 197

LESSON 18

Creating Views That Scroll. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

LESSON 19

Popovers and Modal Views. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

LESSON 20

Tweeting with Twitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

LESSON 21


Basic File Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

LESSON 22

Property Lists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249

LESSON 23

Application Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259

LESSON 24

iTunes File Sharing Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

LESSON 25

Introduction to iCloud Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277

www.it-ebooks.info


LESSON 26

Introduction to Core Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303

LESSON 27

XML Parsing with NSXMLParser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317

LESSON 28


Consuming SOAP Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335

LESSON 29

Touches and Gestures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349

LESSON 30

Printing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

LESSON 31

Basic Animation with Timers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

LESSON 32

Introduction to Core Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375

LESSON 33

Building Universal Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

LESSON 34

Where Am I? Introducing Core Location . . . . . . . . . . . . . . . . . . . . . . . . . . 391

LESSON 35

Introducing Map Kit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403


LESSON 36

Using the Camera and Photo Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413

LESSON 37

Introduction to Core Motion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421

LESSON 38

Building Background-Aware Applications. . . . . . . . . . . . . . . . . . . . . . . . 435

appendix A What’s on the DVD?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451

⊲⊲ Bonus Material
Appendix B Introduction to Programming with Objective-C. . . . . . . . . . . . . . . . . . . . . . 1
Appendix C Introduction to ARC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Appendix D Testing on an iOS Device. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Appendix E

Ad Hoc Distribution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Appendix F

App Store Distribution. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

www.it-ebooks.info



iPhone® and iPad® App
24-Hour Trainer

www.it-ebooks.info


www.it-ebooks.info


iPhone and iPad App
24-Hour Trainer
®

Abhishek Mishra
Gene Backlin

www.it-ebooks.info

®


iPhone® and iPad® App 24-Hour Trainer
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256

www.wiley.com
Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana

ISBN: 978-1-118-13081-0
ISBN: 978-1-118-22507-3 (ebk)
ISBN: 978-1-118-23837-0 (ebk)
ISBN: 978-1-118-26314-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 http://
www.wiley.com/go/permissions.
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 publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard
print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD
or DVD that is not included in the version you purchased, you may download this material at http://booksupport
.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2012930548
Trademarks: DVD and software compilation copyright © 2012 John Wiley & Sons, Inc. All rights reserved. Individual programs are copyrighted by their respective owners and may require separate licensing. This DVD may not be redistributed
without prior written permission from the publisher. The right to redistribute the individual programs on the DVD depends

on each program's license. Consult each program for details. Wiley, Wrox, and the Wrox logo 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. iPhone and iPad are registered trademarks of Apple, Inc. 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


To my wife Sonam, for her love and support
through all the years we’ve been together.
—Abhishek Mishra
This book is being dedicated to the family unit,
past, present and future. May it never lose
sight of its existence.
—Gene Backlin

www.it-ebooks.info


www.it-ebooks.info


About the Authors

Abhishek Mishra  has been developing software for over 12 years and has

experience with a diverse set of programming languages and platforms. He
holds a master’s degree in computer science from the University of London
and is a freelance consultant and trainer specializing in iOS development.
He lives with his wife in London, and when not working, spends his time

stargazing under Scottish skies.

Gene Backlin’s  first calculating machine was a slide rule. If you ask him
about the information revolution, his response would be “fascinating.” He
has developed on computers that loaded programs from paper tape, the revolutionary NeXT computer, which he still has two of, to the iPhone and iPad.
Gene feels very fortunate to have not only seen an industry evolve, but also
to have been an active participant in it. His childhood interest in electronics
helped him break into the computer industry. He started building Heathkit
walkie-talkies, leading him to build the Heathkit H-8 digital computer and
H-9 video terminal, which he still has, in 1978. He taught himself programming using Extended
Benton Harbor Basic and after the IBM-PC was introduced, Gene built the Heathkit H-151
PC-compatible computer, which is still running today.

Gene is owner and principal consultant of MariZack Consulting, formed in 1991 with one purpose —
to help. He has been helping clients for over 30 years, including IBM, McDonnell Douglas, Waste
Management, U.S. Environmental Protection Agency, Nations Bank, Bank of America, Bank One,
and Sears to name a few. He is also a faculty member of DePaul University’s College of Computing
and Digital Media and has previously penned Developing NeXTSTEP Applications in 1995, and
Professional iPhone and iPad Application Development in 2010.

www.it-ebooks.info


Technical Editor

Allan Evans  is a veteran multimedia developer with almost 20 years of

programming experience. He has turned his attention to iOS devices, currently working as a Mobile Architect for Walgreens. He has worked on
iOS projects for Sears Holdings, Tribune Company and CCC Information
Systems. He has spoken about iOS at SecondConf 2010 (www.secondconf

.com) and presented “An Introduction to iOS and Xcode” to the Chicago
Adobe Users Group (www.augchicago.com). In his spare time, he has taken
a liking to physical computing (Arduino and its ilk), and has been known to
write screenplays and graphic novels.

www.it-ebooks.info


Credits
Acquisitions Editor

Vice President and Executive
Group Publisher

Mary James

Richard Swadley
Project Editor

Ed Connor

Vice President and Executive Publisher

Neil Edde
Technical Editor

Allan Evans

Associate Publisher


Jim Minatel
Production Editor

Daniel Scribner

Project Coordinator, Cover

Katie Crocker
Copy Editor

Kim Cofer

Compositor

Craig Woods, Happenstance Type-O-Rama
Editorial Manager

Mary Beth Wakefield

Proofreader

Jen Larsen, Word One
Freelancer Editorial Manager

Rosemarie Graham

Indexer

Ron Strauss
Associate Director of Marketing


David Mayhew

Cover Designer

Ryan Sneed
Marketing Manager

Ashley Zurcher

Cover Image

© webphotographeer / iStockphoto
Business Manager

Amy Knies

Vertical Websites Supervising Producer

Rich Graves
Production Manager

Tim Tate

Vertical Websites Associate Producer

Josh Frank

www.it-ebooks.info



Acknowledgments

This book would not have been possible  without the support of the team at John Wiley and

Sons—Mary James, Ed Connor, and Kim Cofer. I would also like to thank Allan Evans for his keen
eye for detail and Gene Backlin for his continued support throughout the project. It has been my
privilege to work with you. Thank you.

—Abhishek Mishra

I would first like to thank my wife,  Roseann, my son Zachary, and my daughter Marissa, for

putting up with me once again while I was writing this book, and my son Ethan for keeping me
young and remembering what you are to do if this idea ever comes up again, but this time really
hold me to it!
I would also like to thank my mother Mary Louise, father Eugene William and daughter Hannah
Angel, for giving me the gift of themselves and spirit, which I carry with me every day of my life.
I miss you.
To Helen and Jerry, you will never know how much you mean to me, especially the gum!
To Allan, I am glad we were able to work together again. To Abby, it has been fun working together
on this.
This book is more than just words and code. It is time and people. The pages you hold in your hand
are a snapshot of events that somehow managed to come together with the very hard work of a lot
of people; Ed, Mary and Kim specifically, I want to thank you all for everything that you did, it is
greatly appreciated.
Finally I would like to thank Jean-Marc Krikorian especially for once again really doing nothing as
he did in 1995 and 2010.

—Gene Backlin


www.it-ebooks.info


Contents

Introduction

xxv

Lesson 1: Hello iOS!

1

iOS Developer Essentials

1

A Suitable Mac
A Device for Testing
Device Differences
An iOS Developer Account
The Official iOS SDK
The Typical App Development Process
Home Screen Icon
Application Launch Image

Try It

1

2
2
4
6
8
10
10

11

Lesson Requirements
11
Hints12
Step by Step
12

Lesson 2: The iOS Simulator

Features of the iOS Simulator
Installing and Uninstalling Applications

Limitations of the iOS Simulator
Lesson 3: A Tour of Xcode

The Welcome Screen
Selecting a Project Template
Setting up Project Options
An Overview of the Xcode IDE
The Navigator Area
The Editor Area

The Utility Area
The Library Area
The Debugger Area
The Toolbar

17

17
19

20
21

21
21
23
24
24
29
32
34
35
35

Try It

37

Lesson Requirements
37

Hints37
Step-by-Step37
www.it-ebooks.info


CONTENTS

Lesson 4: iOS Application Basics

39

Application States
39
Windows, Views, and View Controllers
41
Frameworks43
The UIButton Class
The UILabel Class

44
45

Creating User Interface Elements
Creating Outlets
Creating Actions
Adding Interactivity

46
50
52

54

Try It

56

Lesson Requirements
56
Hints56
Step-by-Step57

Lesson 5: Introduction to Storyboards

Try It

61

68

Lesson Requirements
68
Hints69
Step-by-Step69

Lesson 6: Handling User Input

Text Fields
Text Views
Try It


81

81
85
86

Lesson Requirements
86
Hints86
Step-by-Step86

Lesson 7: Communicating with Your Users

Alert Views
Action Sheets
Try It

93

93
97
99

Lesson Requirements
99
Hints99
Step-by-Step99

Lesson 8: Adding Images to Your View


The UIImage Class
The UIImageView Class

103

103
105

xiv

www.it-ebooks.info


CONTENTS

Try It

106

Lesson Requirements
106
Hints106
Step-by-Step107

Lesson 9: Pickers

111

Arrays in Objective-C
Try It


113
114

Lesson Requirements
114
Hints115
Step-by-Step115

Lesson 10: Date Pickers

119

Dates in Objective-C
Try It

121
122

Lesson Requirements
123
Hints123
Step-by-Step123

Lesson 11: Custom Pickers

Try It

127


128

Lesson Requirements
128
Hints129
Step-by-Step129

Lesson 12: Navigation Controllers

Navigation Controller Interface
Navigation Bar
Navigation View
Navigation Toolbar

135

135
136
137
137

Navigation Controller Hierarchy
Navigation Stack Management
xib-Based Applications
Storyboard-Based Applications

Try It

137
137

138
138

140

Lesson Requirements
140
Hints140
Step-by-Step140

xv

www.it-ebooks.info


CONTENTS

Lesson 13: Table Views

147

Table View Workflow

148

Display Values
Row Selection

148
148


Table View Styles

148

Delegate Methods
Data Source Methods

149
150

New for iOS 5

150

Table View Additions
150
Constants151
Storyboard Additions
151

Try It

153

Lesson Requirements
153
Hints153
Step-by-Step153


Lesson 14: Static Table Views

Table View Types

161

161

Static161
Dynamic Prototype
161

Table View Design

163

Display Considerations

163

Try It

163

Lesson Requirements
163
Hints164
Step-by-Step164

Lesson 15: Tab Bars and Toolbars


Tab Bars

173

173

Appearance Characteristics
Usage Guidelines

173
174

Toolbars174
Appearance Characteristics
Usage Guidelines

174
174

XIB-Based Xcode 4.2 Changes
Try It

175
176

Lesson Requirements
176
Hints176
Step-by-Step177


xvi

www.it-ebooks.info


CONTENTS

Lesson 16: Creating Page-Based Applications

The PageViewController Class

187

187

Instantiation187
Delegate and Data Source
189
Preparing the Initial Page
189

The Page-Based Application Template
Try It

190
193

Lesson Requirements
193

Hints194
Step-by-Step194

Lesson 17: Creating UI Elements Programmatically

197

UIButton197
UILabel199
UIImageView201
201
Try It
Lesson Requirements
202
Hints202
Step-by-Step202

Lesson 18: Creating Views That Scroll

The UIScrollView Class
Scroll Views and Text Fields
Try It

205

205
208
209

Lesson Requirements

209
Hints210
Step-by-Step210

Lesson 19: Popovers and Modal Views

217

Popovers217
Usage Guidelines
Presenting the Popover
Dismissing the Popover

218
218
218

Modal Views

218

Usage Guidelines
Presentation Styles
Transition Styles
Presenting the Modal View
Dismissing the Modal View

218
219
219

219
219

xvii

www.it-ebooks.info


CONTENTS

Try It

220

Lesson Requirements
220
Hints220
Step-by-Step220

Lesson 20: Tweeting with Twitter

The Tweet Sheet
Try It

231

232
234

Lesson Requirements

234
Hints234
Step-by-Step234

Lesson 21: Basic File Handling

The IOS File System
Introducing the NSFileManager Class
Object Serialization
Try It

239

239
240
241
242

Lesson Requirements
242
Hints243
Step-by-Step243

Lesson 22: Property Lists

Property List Types
Creating Property Lists

249


249
250

Programmatically250
251
Property List Editor

Try It

251

Lesson Requirements
251
Hints252
Step-by-Step252

Lesson 23: Application Settings

Adding a Settings Bundle
Reading Preferences with Code
Try It

259

259
263
263

Lesson Requirements
264

Hints264
Step-by-Step264

xviii

www.it-ebooks.info


CONTENTS

Lesson 24: iTunes File Sharing Support

Try It

269

271

Lesson Requirements
271
Hints271
Step-by-Step271

Lesson 25: Introduction to iCloud Storage

Basic Concepts
Preparing to Use the iCloud Storage APIs
Create an iCloud-enabled App ID
Create an Appropriate Provisioning Profile
Enable Appropriate Entitlements in Your Xcode Project


Checking for Service Availability
Using iCloud Document Storage
Creating a New iCloud Document
Opening an Existing Document
Saving a Document
Searching for Documents on iCloud

Try It

277

277
278
278
281
283

285
285
287
288
288
289

290

Lesson Requirements
290
Hints291

Step-by-Step291

Lesson 26: Introduction to Core Data

Basic Concepts

303

303

Managed Object
Managed Object Context
Persistent Store Coordinator
Managed Object Model

Instantiating Core Data Objects
Writing Managed Objects
Reading Managed Objects
Try It

303
303
303
304

307
308
309
309


Lesson Requirements
309
Hints310
Step-by-Step310

Lesson 27: XML Parsing with NSXMLParser

XML Fundamentals

317

318

Elements and Tags
318
Attributes319
xix

www.it-ebooks.info


CONTENTS

Special Characters
Comments and Processing Instructions

319
319

The NSXMLParser Class


320

SAX and DOM Parsers

320

The NSXMLParserDelegate Protocol
A Simple XML File and How it Is Parsed
Loading the XML Document into an NSData Object
Instantiating an NSXMLParser Object
Instantiating a Delegate Object
Begin Parsing
The XMLParser Delegate Methods

Try It

321
322
323
323
324
324
324

328

Lesson Requirements
328
Hints328

Step-by-Step328

Lesson 28: Consuming SOAP Web Services

Try It

335

341

Lesson Requirements
341
Hints341
Step-by-Step341

Lesson 29: Touches and Gestures

Touch Events

349

349

Touch Phases
Tap Counting

350
350

Gesture Events


350

Gesture Handling
Gesture Recognizer Phases

Try It

351
351

351

Lesson Requirements
352
Hints352
Step-by-Step352

Lesson 30: Printing

359

Preparing Content for Printing

360

UIPrintInfo360
UIPrintPaper
361
UIPrintInteractionController362


xx

www.it-ebooks.info


CONTENTS

Try It

363

Lesson Requirements
363
Hints364
Step-by-Step364

Lesson 31: Basic Animation with Timers

Animating UIView Subclasses
Try It

367

368
370

Lesson Requirements
370
Hints370

Step-by-Step370

Lesson 32: Introduction to Core Image

Images and Filters
Using Core Image
Try It

375

375
377
378

Lesson Requirements
378
Hints378
Step-by-Step379

Lesson 33: Building Universal Applications

383

Examining the Universal Application Template
Try It

383
386

Lesson Requirements

386
Hints386
Step-by-Step387

Lesson 34: Where Am I? Introducing Core Location

Handling Location Updates
Handling Errors and Checking Hardware Availability
Geocoding and Reverse Geocoding

Obtaining Compass Headings
Try It

391

393
394
396

397
398

Lesson Requirements
398
Hints398
Step by-Step
399

Lesson 35: Introducing Map Kit


Adding Annotations

403

405

xxi

www.it-ebooks.info


CONTENTS

Try It

407

Lesson Requirements
407
Hints408
Step-by-Step408

Lesson 36: Using the Camera and Photo Library

Try It

413

416


Lesson Requirements
416
Hints417
Step-by-Step417

Lesson 37: Introduction to Core Motion

Accelerometers and Gyroscopes
Core Motion Basics
Checking Hardware Availability
Handling Accelerometer Events
Handling Gyroscope Events
Try It

421

421
423
425
426
427
427

Lesson Requirements
427
Hints428
Step-by-Step428

Lesson 38: Building Background-Aware Applications


Understanding Background Suspension
Executing Background Code
Creating Local Notifications
Try It

435

435
436
438
439

Lesson Requirements
440
Hints440
Step-by-Step440

Appendix A: What’s on the DVD?

447

System Requirements
447
Using the DVD on a PC
447
Using the DVD on a Mac
448
What’s on the DVD
448
Troubleshooting448

Customer Care
449
Index

451

xxii

www.it-ebooks.info


CONTENTS

Bonus Material
Appendix B: Introduction to Programming with Objective-C 1

Fundamental Programming Concepts

1

Typing Your Program
2
Compiling2
2
Linking to Create an Executable
Testing and Debugging
3
How Xcode Fits Into This Picture
3


Variables, Statements, and Expressions

3

Variables5
Statements7
Expressions and Operators
8

Making Decisions and Performing Repetitive Tasks
The if and if ... else statements
The for Statement
The while Statement
The do…while Statement
The break and continue Statements

Introduction to Object-Oriented Programming (OOP)
The Need for Object-Oriented Programming
Key Concepts of Object-Oriented Programming
Creating an Objective-C Class
Implementing the Class
Sending Messages to Objects
Instantiating Objects
Objective-C Properties

Appendix C: Introduction to ARC

Object Ownership
Converting Projects to ARC


10
10
13
15
16
17

17
19
20
25
30
32
33
33

37

37
40

Appendix D: Testing on an iOS Device

55

Obtaining and Registering UDIDs
Creating an App ID (Bundle Identifier)
Creating a Development Certificate
Creating a Provisioning Profile
Configuring Your Project


55
57
58
60
62

xxiii

www.it-ebooks.info


×