Suchen und Finden

Titel

Autor

Inhaltsverzeichnis

Nur ebooks mit Firmenlizenz anzeigen:

 

iPhone Advanced Projects

iPhone Advanced Projects

David Mark, Dylan Bruzenak, Joachim Bondo, Owen Goss, Peter Honeder, Ray Kiddy, Steve Finkelstein, T

 

Verlag Apress, 2010

ISBN 9781430224044 , 392 Seiten

Format PDF, OL

Kopierschutz Wasserzeichen

Geräte

34,99 EUR

Mehr zum Inhalt

iPhone Advanced Projects


 

Dedication Page

4

Contents at a Glance

5

Table of Contents

6

Foreword

12

About the Technical Reviewer

13

Preface

14

Organization

15

What’s in the Book

15

CHAPTER 1: Everything You Ever Wanted to Know About Particle Systems

19

Adding Life to Your Game with Particles

21

Basic Particle Systems and You

23

Overview of the Sample Code

24

Basic Game Flow

25

The Anatomy of a Particle System

26

Code! Finally!

28

Slight Tangent About Degenerates

31

Back to the Code

32

Random Numbers and Initial Conditions

35

Emitting Particles

36

Tweaking Your Particle System

37

May the Force Be with Your Particles

41

Amazing Technicolor Dream Particle

44

Off on a Tangent: Lerping

44

Color-Changing Particles

46

Summary

51

Chapter 2: Chess on the ’Net: Correspondence Gaming with Deep Green

55

Deep Green, an Already Awesome Application

56

The Tasks at Hand

58

Inviting a Friend to a Game

59

Accepting the Invitation

59

Making a Move

59

Getting Notified

59

The Tools of the Trade

60

Stop Talking, Start Coding!

61

Installing the Tools

61

Coding the Web Service

63

Accepting the Challenge on the Device

70

Registering URL Scheme Support with iPhone OS

70

Handling the URL Request

70

Separating Data and Representation on the Server

72

Making a Move

73

On the Device

73

On the Server

75

Summary

77

Chapter 3: Audio Streaming: An Exploration into Core Audio

80

Hey, I Could Write an App to Play Music

81

MPMoviePlayerController: Hey, This Is Easy! Right?

81

Finding a Better Approach

83

The System-Sound Way

84

AVAudioPlayer: The Not-Available-in-Beta Way

84

DOWNLOADING DATA WITH NSURLCONNECTION

87

Doing It the Cowboy Way with Core Audio

89

Getting Halfway There: Audio Queue Services

89

A WORD ON PROGRAMMING LANGUAGES

90

BEWARE THE SIMULATOR

90

Getting the Rest of the Way There: Audio File Stream Services

96

BUFFERING ON MOBILE DEVICES

99

THE AUDIO SESSION

107

Putting It All into an App

108

One More Thing

108

Launch It

111

iPhone 3.0 and Further Work

111

Summary

112

Chapter 4: You Go Squish Now! Debugging on the iPhone

115

Assumed Knowledge

116

Objective-C vs. C and C++

118

While You’re Writing That Code

119

Custom Asserts

119

Custom Logging

121

Using #define

122

Crash!

123

Getting a Crash Log from Your Testers

123

You Have Been Saving Your dSYM Files, Right?

124

Symbolicating a Crash Log

124

Using atos

125

Reproducing Rare Crashes

126

Thread

126

System

127

Race Conditions

127

The Scientific Method of Debugging

127

Forming a Hypothesis

127

Creating a Test for Your Hypothesis

128

Proving or Disproving Your Hypothesis

129

Increasing the Probability of the Crash

129

So, You Have a Call Stack

129

Starting Code

129

What Is a Memory Stomp?

132

Buffer Overruns

133

Calling a Deleted Method

133

Returning to a Deleted Object

134

Identifying a Mem Stomp

136

Tools to Detect Memory Problems

137

malloc_error_break

137

NSZombieEnabled

140

Enable Guard Malloc

143

Watching Variables

145

Link Map Files

149

Summary

151

Chapter 5: Building Data-Driven Applications with Active Record and SQLite

154

A Short Road Off a High Cliff (How I Got Here)

154

Ready! Set! Wait, What? (Why I Decided to Write a To-Do Application)

155

Data-Driven Applications on the iPhone

156

Active Record: A Simple Way of Accessing Data

157

Writing a Database Wrapper Around the C API: ISDatabase

157

Setting Up the Example Project

158

Creating and Initializing the Database

161

Opening a Database Connection

162

Making Simple Requests

165

More Advanced SQL

171

Preventing Duplicate Create Statements

171

Handling Parameters

173

Refactoring and Cleanup

175

Grouping Statements into Transactions

176

Writing a Simple Active Record Layer: ISModel

177

Maintaining the Database Connection

178

The Model Object: Grocery Item

178

How Groceries Are Mapped

179

Saving

181

Updating

183

Deleting

183

Finding Grocery Items

184

Putting It All Together

187

Simple Migration Handling

189

Alternative Implementations

192

Summary

193

Chapter 6: Core Data and Hard-Core Design

196

Where Did Core Data Come From?

197

The Client Is King

197

A Very First Core Data App

198

First, Steal Code (Not Music!)

199

A View to an Object, Any Object

200

Our Very First Crash, or Perhaps Not

206

CoreData Tutorial for iPhone OS: Managing Model Migrations

207

The Easy Migrations Are Easy

207

Adding a New Entity

210

Using Key-Value Coding to Create a Reusable Object

212

Remote Databases: It’s All Net

216

Summary

219

Chapter 7: mart In-Application E-mail with Core Data and Three20

223

Planning a Simple Offline SMTP Client

224

Creating the User Interface

225

Diving into Xcode

225

Setting Up Instance Variables in OfflineMailerAppDelegate.h

227

Initializing the UIApplication Delegate

229

Working with Core Data

230

Understanding the Core Data Stack

233

Adding Three20

233

Journeying Through the User Interface

236

Managing Top-Level Data with DataManager

238

Diving into Three20 and TTMessageController

240

Composing and Sending Messages

242

Creating the Core Data Model

247

Hacking SKPSMTPMessage to Support Threaded Message Sending

251

Setting Up the NSRunLoop on SKPSMTPMessage

251

Switching the Bits Back to Online Mode

253

Summary

256

Chapter 8: How iTap Tackles the Challenges of Networking

260

Meet iTap and iTap Receiver

261

iTap

262

iTap Receiver

262

How the Idea for iTap Emerged and Evolved

263

The Main Challenges

263

No Physical Buttons on the iPhone

263

Third-Party Applications Cannot Use USB or Bluetooth

264

Supporting Both Mac and PC

265

User-Friendliness Demands Autodiscovery of Computers and Devices

266

WiFi Networking on the iPhone from a Programmer’s Perspective

266

About the Sample Code

267

Introducing Sockets

268

Address Family

268

Socket Type

268

Protocol

269

Creating a Socket

269

Local and Remote Addresses

269

BYTE ORDERING

270

Setting a Socket’s Local and Remote Address

271

Sending and Receiving Data

271

Raw BSD Sockets vs. User Experience

272

Using CFSocket to React to Networking Events

273

Reacting to Incoming Datagrams

273

Querying the Network Configuration

275

Introducing IO Controls

275

Querying the Names of the Available Interfaces Using the SIOCGIFCONF IO Control

275

Querying an Interface’s Flags Using the SIOCGIFFLAGS IO Control

277

Other Interesting IO Controls

278

Contacting All Devices on the Network

278

Detecting WiFi Availability

279

Playing by the Power Management Rules

280

Informing iPhone OS About Your Application’s Networking Requirements

280

Minimizing Power Consumption While the iPhone Is Locked

281

The Networking Subsystem of iTap

282

To use Bonjour or Not to Use Bonjour

282

Using Notifications to Communicate Between Components

283

Our Custom Autodiscovery Solution

284

Summary

286

Chapter 9: Fake It ’Til You Make It: Tips and Tricks for Improving Interface Responsiveness

289

Plotting of Historical Stock Prices with AAPLot

290

Storing Data Between Runs

293

WRITING TO THE IPHONE’S NAND FLASH MEMORY

294

Using Plists to Persist Data

294

Saving Data to the iPhone Application Sandbox

295

Shipping AAPLot with Placeholder Data

296

Extending the App for Multiple Stock Graphs: StockPlot

298

Concurrency

302

NSOperation, NSOperationQueue, and Blocks

303

Installing the Plausible Blocks Compiler and Adding It to the Project

304

Using Blocks, NSOperation, and NSOperationQueue in StockPlot

305

Displaying Large Amounts of Data Efficiently

308

Zooming a UIScrollView

310

UIScrollView Zooming Under the Covers

310

Resetting Resolution in a UIScrollView after a Zoom Operation

311

Drawing into an Off-Screen Context

314

Observations, Tips, and Tricks

319

Summary

320

Chapter 10: Demystifying the Apple Push Notification Service

323

What Is the Apple Push Notification Service?

324

What You’ll Need

324

Step 1: Create the Client

324

The Application Delegate

325

Registration

325

Device Token Acquisition

326

Check for Errors

327

Handling Incoming Notifications

327

Sounds

328

Build and Go! Er, Not So Fast...

328

Step 2: Create the Certificate

329

A Walk-Through of the Program Portal Process

329

Back to the Portal

338

Add the Mobile Provisioning File for Code Signing

339

Step 3: Set Up the Server

341

A Walk-Through of What This Script Does

343

Download Server File

344

The Home Stretch

346

Wiring Up the Client

346

Additional Considerations/Advanced Topics

351

Feedback Server

351

SSL Server Connections

352

Moving from Development Sandbox to Production

352

Development vs. Ad Hoc

353

Mobile Provisioning Files

353

Debugging

353

User Experience

353

Open Source Code

354

Hosted Solutions

354

Summary

354

Chapter 11: Environment Mapping and Reflections with OpenGL ES

357

The Beginnings

357

First Steps: OpenGL Lighting

359

Turning to Environment Mapping

362

Spherical Environment Mapping Implementation

363

Combining Environment Mapping and Diffuse Textures

366

Per-Pixel Reflections

369

iPhone 3GS

372

Summary

373

Index

375