Contents

Contents at a Glance

About the Authors

About the Technical Reviewer

Acknowledgments

Introduction

imagesChapter 1: Getting Started

What Is Core Data?

History of Persistence in iOS

Creating a Basic Core Data Application

Understanding the Core Data Components

Creating a New Project

Running Your New Project

Understanding the Application's Components

Fetching Results

Inserting New Objects

Initializing the Managed Context

Adding Core Data to an Existing Project

Adding the Core Data Framework

Creating the Data Model

Initializing the Managed Object Context

Summary

imagesChapter 2: Understanding Core Data

Core Data Framework Classes

The Model Definition Classes

The Data Access Classes

Key-Value Observing

The Query Classes

How the Classes Interact

SQLite Primer

Reading the Data Using Core Data

Summary

imagesChapter 3: Storing Data: SQLite and Other Options

Visualizing the User Interface

Using SQLite as the Persistent Store

Configuring the One-to-Many Relationship

Building the User Interface

Configuring the Table

Creating a Team

The Player User Interface

Adding, Editing, and Deleting Players

Seeing the Data in the Persistent Store

Using an In-Memory Persistent Store

Creating Your Own Custom Persistent Store

Initializing the Custom Store

Mapping Between NSManagedObject and NSAtomicStoreCacheNode

Serializing the Data

Using the Custom Store

What About XML Persistent Stores?

Summary

imagesChapter 4: Creating a Data Model

Designing Your Database

Relational Database Normalization

Using the Xcode Data Modeler

Viewing and Editing Attribute Details

Viewing and Editing Relationship Details

Using Fetched Properties

Creating Entities

Creating Attributes

Creating Relationships

Name

Destination and Inverse

Transient

Optional

To-Many Relationship

Count (Minimum and Maximum)

Delete Rule

Summary

imagesChapter 5: Working with Data Objects

Understanding CRUD

Creating the Shape Application Data Model

Building the Shape Application User Interface

Enabling User Interactions with the Shapes Application

Generating Classes

Modifying Generated Classes

Using the Transformable Type

Validating Data

Custom Validation

Invoking Validation

Default Values

Undoing and Redoing

Undo Groups

Limiting the Undo Stack

Disabling Undo Tracking

Adding Undo to Shapes

Summary

imagesChapter 6: Refining Result Sets

Building the Test Application

Creating the Org Chart Data

Reading and Outputting the Data

Filtering

Expressions for a Single Value

Expressions for a Collection

Comparison Predicates

Compound Predicates

Subqueries

Aggregating

Sorting

Returning Unsorted Data

Sorting Data on One Criterion

Sorting on Multiple Criteria

Summary

imagesChapter 7: Tuning Performance and Memory Usage

Building the Application for Testing

Creating the Core Data Project

Creating the Data Model and Data

Creating the Testing View

Building the Testing Framework

Adding the Testing Framework to the Application

Running Your First Test

Faulting

Firing Faults

Faulting and Caching

Refaulting

Building the Faulting Test

Taking Control: Firing Faults on Purpose

Prefetching

Caching

Expiring

Memory Consumption

Brute-Force Cache Expiration

Expiring the Cache Through Faulting

Uniquing

Improve Performance with Better Predicates

Using Faster Comparators

Using Subqueries

Analyzing Performance

Launching Instruments

Understanding the Results

Summary

imagesChapter 8: Versioning and Migrating Data

Versioning

Lightweight Migrations

Migrating a Simple Change

Migrating More Complex Changes

Renaming Entities and Properties

Creating a Mapping Model

Understanding Entity Mappings

Understanding Property Mappings

Creating a New Model Version That Requires a Mapping Model

Creating a Mapping Model

Migrating Data

Running Your Migration

Custom Migrations

Making Sure Migration Is Needed

Setting Up the Migration Manager

Running the Migration

Summary

imagesChapter 9: Managing Table Views Using a Fetched Results Controller

Understanding NSFetchedResultsController

The Fetch Request

The Managed Object Context

The Section Name Key Path

The Cache Name

Understanding NSFetchedResultsController Delegates

Using NSFetchedResultsController

Implementing NSFetchedResultsController in League Manager

Implementing the NSFetchedResultsController

Implementing the NSFetchedResultsControllerDelegate Protocol

Indexing Your Table

Responding to Data Change

Summary

imagesChapter 10: Using Core Data in Advanced Applications

Creating an Application for Note and Password Storage and Encryption

Setting Up the Data Model

Setting Up the Tab Bar Controller

Adding the Tab

Incorporating NSFetchedResultsController into MyStash

Creating the Interface for Adding and Editing Notes and Passwords

Splitting Data Across Multiple Persistent Stores

Using Model Configurations

Adding Encryption

Persistent Store Encryption Using Data Protection

Data Encryption

Sending Notifications When Data Changes

Registering an Observer

Receiving the Notifications

Seeding Data

Adding Categories to Passwords

Creating a New Version of Seeded Data

Error Handling

Handling Core Data Operational Errors

Handling Validation Errors

Handling Validation Errors in MyStash

Summary

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.253.62