Professional iOS Database Application Programming, 2nd Edition
Buy Rights Online Buy Rights

Rights Contact Login For More Details

  • Wiley

More About This Title Professional iOS Database Application Programming, 2nd Edition

English

Updated and revised coverage that includes the latest versions of iOS and Xcode

Whether you're a novice or experienced developer, you will want to dive into this updated resource on database application programming for the iPhone and iPad. Packed with more than 50 percent new and revised material - including completely rebuilt code, screenshots, and full coverage of new features pertaining to database programming and enterprise integration in iOS 6 - this must-have book intends to continue the precedent set by the previous edition by helping thousands of developers master database application programming.

Shows you how to store data using SQLite, model and manage data using Core Data, and integrate with Web ServicesExplains how to take advantage of the built-in capabilities of the iPhone and iPadDetails techniques for integrating iOS applications into enterprise class systemsEncourages you to take advantage of multi-core processors, store data in the cloud, and use storyboards to develop the UI for your app

By the end of the book, you will be able to confidently implement a data driven application for the iPhone and iPad and integrate an iOS application within an existing enterprise system.

English

Patrick Alessi creates data-centric applications for clients ranging from small businesses to the United States Air Force. He created the popular MotivationalQuotes app, as well as CNotes. He is the author of Professional iPhone and iPad Database Application Programming and Beginning iOS Game Development. Currently, he focuses his efforts on the promise of mobility and connected applications for mobile devices.

English

INTRODUCTION xxi

PART I: MANIPULATING AND DISPLAYING DATA ON THE IPHONE AND IPAD

CHAPTER 1: INTRODUCING DATA-DRIVEN APPLICATIONS 3

Building a Simple Data-Driven Application 4

Creating the Project 4

Adding a UITableView 7

Retrieving Data 9

Implementing Your Data Model Class 9

Displaying the Data 12

Further Exploration 18

Design Patterns 18

Reading a Text File 18

Moving Forward 19

CHAPTER 2: THE IOS DATABASE: SQLITE 21

What Is SQLite? 22

The SQLite Library 22

SQLite and Core Data 23

Building a Simple Database 24

Designing the Database 25

Creating the Database 27

Populating the Database 29

Tools to Visualize the SQLite Database 33

Connecting to Your Database 36

Starting the Project 36

The Model Class 39

The DBAccess Class 40

Parameterized Queries 49

Writing to the Database 50

Displaying the Catalog 51

Viewing Product Details 53

Moving Forward 56

CHAPTER 3: DISPLAYING YOUR DATA: THE UITABLEVIEW 57

Customizing the Table View 58

Table View Cell Styles 58

Adding Subviews to the contentView 61

Subclassing UITableViewCell 65

Implementing Sections and an Index 70

Implementing Search 76

Optimizing Table View Performance 82

Reusing Existing Cells 82

Opaque Subviews 83

Custom Drawn Cells with drawRect 85

UI Conventions for Accessory Views 86

Moving Forward 86

CHAPTER 4: USER INTERFACE ELEMENTS 87

Building Your Interface with Storyboards 88

Starting the Storyboard Example Application 89

Adding the Sub-detail Screen to the Storyboard 90

Adding a Modal Screen to the Storyboard 91

Displaying Master/Detail Data with the Split View Controller 92

Introducing the UISplitViewController 93

The UISplitViewControllerDelegate Protocol 95

Starting the Split View Sample Application 95

Building the Detail Interface 98

Adding Surveys with the Master/Detail View 100

Displaying Data in a Popover 105

Building the InfoViewController 106

Displaying the UIPopoverController 108

Gesture Recognizers 109

The UIGestureRecognizer Class 109

Using Gesture Recognizers 110

File Sharing Support 114

Enable File Sharing in the Sample Application 114

Serializing the Survey Data Array 114

Deserializing and Loading the Survey Data Array 116

Sharing the Data 117

Moving Forward 119

II: MANAGING YOUR DATA WITH CORE DATA

CHAPTER 5: INTRODUCING CORE DATA 123

The Basics of Core Data 124

The Core Data Architecture 125

The Core Data Stack 125

SQLite and Core Data 127

Core Data and iCloud 127

Data Protection 128

Using Core Data: A Simple Task Manager 129

Creating the Project 129

Examining the Template Code 130

Modifying the Template Code 142

Moving Forward 147

CHAPTER 6: MODELING DATA IN XCODE 149

Modeling Your Data 150

Defi ning Entities and Their Attributes 151

Adding Relationships Between Entities 155

Creating Fetched Properties and Fetch Request Templates 158

Creating Custom NSManagedObject Subclasses 161

Implementing Validation Rules 163

Implementing Default Values 164

Creating the Tasks Model 165

Moving Forward 167

CHAPTER 7: BUILDING A CORE DATA APPLICATION 169

The Tasks Application Architecture 170

The Data Model 170

The Class Model 170

The User Interface 171

Coding the Application 172

MasterViewController and the Basic UI 173

Generating the Managed Object Subclasses 176

Adding and Viewing Tasks 177

Building the ViewTaskController 177

Changes to the MasterViewController 182

Building the Editing Controllers 184

Editing Text with the EditTextViewController 185

Setting Priorities with the EditPriorityViewController 189

Adding and Editing Locations with the EditLocationViewController 193

Modifying Dates with the EditDateController 199

Finishing Up the Editing Controllers 203

Displaying Results in the MasterViewController 206

Sorting Results with NSSortDescriptor 206

Filtering Results with NSPredicate 207

Generating Grouped Tables Using the NSFetchedResultsController 208

Implementing Custom Managed Objects 213

Coding a Dynamic Property 213

Defaulting Data at Runtime 214

Validating a Single Field 215

Multifi eld Validation 216

Moving Forward 218

CHAPTER 8: CORE DATA–RELATED COCOA FEATURES 219

Key-Value Coding 220

Keys and Keypaths 220

Setting Values Using Keys 222

Collection Operators 223

Additional Considerations When Using KVC 223

Key-Value Observing 224

Observing Changes to an Object 224

Automatic and Manual Implementations of KVO 225

Key-Value Observing Example 226

Using NSPredicate 231

Creating Predicates 231

Using Predicates 234

Sort Descriptors 234

Moving Forward 235

CHAPTER 9: CORE DATA MIGRATION AND PERFORMANCE 237

Model Versioning and Schema Migration 238

Model Versioning 239

Lightweight Migration 241

Generating a Mapping Model 244

Safely Threading with Core Data 248

Designing for Threading 248

Threading and Core Data 249

Threading with NSOperation 249

Core Data Threading Example 250

Core Data Performance 258

Faulting 258

Data Store Types 259

Storing Binary Data 260

Entity Inheritance 260

Runtime Performance 261

Managing Changes with the Fetched Results Controller 262

Performance Analysis Using Instruments 264

Starting Instruments 265

The Instruments Interface 266

The Core Data Instruments 267

Moving Forward 268

PART III: APPLICATION INTEGRATION USING WEB SERVICES

CHAPTER 10: WORKING WITH XML ON THE IPHONE 271

iOS SDK and the Web 272

Web Application Architecture 272

Synchronous Data Retrieval 273

The URL Loading System 273

Web Access Sample 275

Requesting Data from the Server 277

XML and the iPhone SDK 284

Brief Overview of XML 284

Parsing XML with NSXML Parser 285

Extending the Example, Parsing the XML 286

Generating XML with libxml 292

XML Generation Sample 293

Moving Forward 299

CHAPTER 11: INTEGRATING WITH WEB SERVICES 301

Network Application Architecture 302

Two-Tier Architecture 302

Three-Tier Architecture (n-tier) 303

Application Communication 304

Introducing Web Services 304

SOAP Messaging 306

The REST Protocol 307

Example 1: Location-Based Search 308

Starting Out 308

Building the Interface 309

Core Location 310

The Local Search API 312

Using the Search Bar 314

Handling the Web Service Response 317

Example 2: Content Analysis 329

Getting Started 330

Building the User Interface 331

Implementing the POST Call 332

Receiving the XML Response 334

Parsing the Response XML 335

Finishing Up 337

Moving Forward 338

APPENDIX A: TOOLS FOR TROUBLESHOOTING YOUR APPLICATIONS 339

Instruments 339

Starting Instruments 340

The Trace Document 341

Objective-C Memory Management 342

Sample Memory Leak Application 344

Analyzing a Memory Leak in Instruments 346

The Static Analyzer 349

INDEX 353

loading