• No results found

Learning ios Programming

N/A
N/A
Protected

Academic year: 2021

Share "Learning ios Programming"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

SECOND EDITION

Learning

iOS

Programming

Alasdair Allan

(2)

Table of

Contents

Preface

ix

1.

Why

Go

Native? 1

TheProsandCons 1

Why

Write Native

Applications?

2

The Release

Cycle

3

Build It and

They

WillCome 4

2.

Becoming

a

Developer

7

Registering

as aniOS

Developer

7

Enrolling

intheiOS

Developer

Program.

9

The Mac

Developer Program

10

Installing

the iOSSDK 11

What

Happens

When ThereIsaBeta? 13

Preparing

Your iOSDevice 14

Creating

a

Development

Certificate 15

Getting

theUDIDofYour

Development

Device 17

Creating

an

App

ID 18

Creating

aMobile

Provisioning

Profile 19

Making

Your Device Available for

Development

20

3. Your

First

iOS

App

23

Objective-C

Basics 23

Object-Oriented Programming

23

The

Objective-C Object

Model 25

The Basicsof

Objective-C Syntax

27

Creating

a

Project

28

Exploring

the

Project

inXcode 32

Our

Project

inInterface Builder 39

Building

theUserInterface 41

(3)

Running

the

Application

inthe Simulator 46

Putting

the

Application

onYouriPhone 48

4.

Coding

in

Objective-C

49

Declaring

and

Defining

Classes

49

Declaring

aClass with the Interface 49

Defining

aClasswith the

Implementation

51

Object Typing

52

Properties

52

Synthesizing

Properties

54

TheDot

Syntax

54

Declaring

Methods 54

Calling

Methods 55

Calling

Methodson nil 56

Memory

Management

56

Creating Objects

57

The Autorelease Pool 57

The

alloc,

retain, copy, and release

Cycle

58 AutomaticReference

Counting

59

The deallocMethod 60

Responding

to

Memory

Warnings

60

Fundamental iOS

Design

Patterns 60

The Model-View-Controller Pattern 61

ViewsandViewControllers 61

The

Delegates

and DataSource Pattern 62

Conclusion 63

5.

Table View-Based

Applications

65

Creating

the

Project

65

Creating

aTable View 66

Running

the Code 71

Populating

the TableView 71

Building

aModel 73

Adding

CitiestotheGuide 78

Adding

Images

toYour

Projects

80

Connecting

the Controllerto theModel 81

Mocking

Up

Functionality

with Alert Windows 84

Adding Navigation

Controlstothe

Application

85

Adding

a

City

View 87

Edit Mode 94

Deleting

a

City Entry

98

Adding

a

City Entry

99

(4)

Capturing

the

City

Data 109

6.

Other View Controllers

115

Utility Applications

115

Making

the

Battery Monitoring Application

116

Tab Bar

Applications

127

Adding

Another TabBar Item 128

Combining

ViewControllers 132

Modal View Controllers 137

Modifying

the

City

Guide

Application

139

The

Image

PickerViewController 148

Adding

the

Image

Picker to the

City

Guide

Application

148

Master-Detail

Applications

157

Creating

aUniversal

Application

158

Popover

Controllers 167

7.

Connecting

tothe Network 169

Detecting

NetworkStatus 169

Apple's Reachability

Class 169

Embedding

aWeb Browser in Your

App

181

A

Simple

WebView Controller 182

Displaying

Static HTML Files 191

Getting

DataOut ofa UlWebView 192

Sending

Email 192

Getting

Datafromthe Internet 198

Synchronous Requests

198

Asynchronous

Requests

198

Using

WebServices 199

8.

Handling

Data

219

Data

Entry

219

UITextField and Its

Delegate

219

UITextViewandIts

Delegate

221

Parsing

XML 223

Parsing

XMLwith libxml2 224

Parsing

XMLwithNSXMLParser 225

Parsing

JSON

227

NSJSONSerialization

227

The

JSON

Framework 229

Retrieving

TwitterTrends 230

Using

theTwitterFramework 232

TheTwitterTrends

Application

232

(5)

Introductionto

Regular

Expressions

240

Storing

Data 245

Using

Flat Files 245

Storing

Information in a

SQL

Database 246

Core Data 254

9.

Using

Sensors

255

Hardware

Support

255

Network

Availability

256

Camera

Availability

256

Audio

Input Availability

256

GPS

Availability

257

Magnetometer

Availability

257

Setting

Required

Hardware

Capabilities

258

Persistent WiFi 258

Background

Modes 259

Differences BetweeniPhoneand iPad 260

Using

the Camera 261

TheCore Motion Framework 262

Pulling

MotionData 262

Pushing

MotionData 263

TheAccelerometer 264

The

Gyroscope

268

The

Magnetometer

270

Accessing

the

Proximity

Sensor 275

Using

Vibration 277

10.

Geolocation

and

Mapping

279

The

Core Location Framework 279

Device

Heading

281

Location-Dependent

Weather

283 Reverse

Geocoding

284 Forward

Geocoding

284 CLPlacemark

Objects

285

Modifying

the Weather

Application

285

User Location and

MapKit

293

Annotating Maps

301

11.

Introduction

to

iCIoud

309

HowCanI UseiCIoud? 309

iCIoud

Backup

310

Provisioning

Your

Application

for iCIoud 310

(6)

Wrapping

Up

320

12.

Integrating

Your

Application

323

Application

Preferences 323

TheAccountsFramework 333

TheTwitter Framework 335

Sending

Tweets 336

CustomURLSchemes 337

Using

CustomSchemes 337

Registering

Custom Schemes 339

Media

Playback

344

Using

the Address Book 349

Interactive

People Picking

349

Programmatic People Picking

353

Sending

Text

Messages

353

13.

Distributing

Your

Application

355

Adding

Missing

Features 355

Adding

anIcon 355

Adding

aLaunch

Image

359

Changing

the

Display

Name 364

Enabling

Rotation 365

Building

and

Signing

366

Ad Hoc Distribution 367

Developer-to-Developer

Distribution 372

App

StoreDistribution 373

Submitting

to the

App

Store 374

Building

Your

Application

for

App

Store Distribution 380

The

App

Store Resource Center 383

Reasonsfor

Rejection

384

14.

Going

Further

389

Cocoa and

Objective-C

389

The iOS SDK 389 Web

Applications

390

PhoneGap

390 Core Data 391

In-App

Purchase 391 MKStoreKit 392 Core Animation 392 Game Kit 392

Writing

Games 393

(7)

Hardware Accessories 394

References

Related documents

Ribosomal protein S6 kinase alpha-3 (RSK2) is responsible for H3S10 phosphorylation at the level of genes that are transcriptionally modulated by High Mobility Group A1

If U-100 insulin syringes are used, since their markings are in units and are designed and intended for use with the less concentrated U-100 insulin products, it is extremely

resuscitation mask adult (inflatable cuff type) L2-180 1 oxygen reservoir Not Applicable 1 vi.. oxygen mask (& tubing) – adult simple type Not Applicable

What briefing is given to aircrew members just prior to departing for their aircraft that provides additional information not available during the premission

Although it is the primary function of the eyelids to protect the cornea, a secondary eyelid function is to participate with other muscles in facial expression,

The substance or effect of the decision or order appealed from is the ISSUANCE on August 19, 2020 to Kyle Johnson, of a Site Permit (renovation and addition to single family

the extension of the personal scope of anti-discrimination rules to self-employed persons, but limited its statement to the protection of all working pregnant women against