Home > Store

Learning Core Data for iOS with Swift: A Hands-On Guide to Building Core Data Applications, 2nd Edition

Register your product to gain access to bonus material or receive a coupon.

Learning Core Data for iOS with Swift: A Hands-On Guide to Building Core Data Applications, 2nd Edition

eBook (Watermarked)

  • Your Price: $38.39
  • List Price: $47.99
  • About Watermarked eBooks
  • This PDF will be accessible from your Account page after purchase and requires PDF reading software, such as Acrobat® Reader®.

    The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

    Watermarked eBook FAQ

Description

  • Copyright 2016
  • Dimensions: 7" x 9"
  • Edition: 2nd
  • eBook (Watermarked)
  • ISBN-10: 0-13-412007-8
  • ISBN-13: 978-0-13-412007-2

Get Started Fast with Core Data App Development Using iOS 9, Swift, and Xcode 7

 

Core Data is a remarkably mature, stable, and fast platform for data access, and Swift is a world-class language for applying it. Now, there’s a complete guide to using Core Data and Swift together in production apps. Tim Roadley shows you how to gain the benefits of a relational database without writing SQL queries, so you can get more done faster, with less coding.

This book fully reflects Apple’s latest iOS 9 platform innovations and teaches Core Data entirely with Swift examples. It guides you step-by-step through creating a modern data-driven iOS app that fully integrates iCloud via CloudKit for public data sharing.

Roadley introduces up-to-date patterns and best practices designed to overcome the frustrations of Core Data development. Each chapter builds on the last, introducing new topics in the order you’ll implement them and extending your skills simply and intuitively.

Each chapter offers downloadable project code, along with exercises to help you explore even further, either as a self-learner or a student in an iOS development course. Roadley even shows how to build helper classes that simplify reuse of his example code.

If you’re an experienced iOS developer, here are all the Swift skills and resources you need to integrate data into any app—quickly, easily, and painlessly.

Coverage includes

  • Understanding what Core Data is and what it can (and can’t) do
  • Configuring basic managed object models, and choosing data types
  • Expanding data models without introducing errors
  • Using relationships and entity inheritance to unlock more power
  • Delivering memory-efficient, high performance table views
  • Enabling users to easily modify managed object attributes
  • Generating persistent stores of preloaded default data
  • Using Deep Copy to copy objects and relationships between persistent stores
  • Optimizing performance by eliminating bottlenecks and offloading intensive tasks to the background
  • Implementing efficient search
  • Integrating diverse iCloud accounts and preferences
  • Mastering advanced iCloud integration, including entity-level seeding and unique object de-dupe
  • Leveraging public CloudKit databases to sync data across users with different iCloud accounts

About the Website

All code samples are available for download at timroadley.com.

informit.com/learningseries
timroadley.com

Sample Content

Table of Contents

Preface     xv
1   Your First Core Data Application     1
What Is Core Data?     1
     Persistent Store Coordinator     2
     Managed Object Model     4
     Managed Object Context     4
When to Use Core Data     5
Introducing the Groceries Application     5
Adding Core Data to an Existing Application     6
     Implementing the Core Data Helper     7
     Adding Paths     10
     Adding the Core Data Stack     10
     Adding the Setup Section     12
     Adding the Saving Section     13
Adding a Managed Object Model File     14
Summary     15
Exercises     15
2   Managed Object Model Basics     17
What Is a Managed Object Model?     17
Entities     18
Attributes     20
Integer 16/32/64     21
Float and Double     22
     Decimal     23
     String     23
     Boolean     23
     Date     23
     Binary Data     23
     Transformable     24
Attribute Settings     25
Subclassing NSManagedObject     27
Scalar Properties for Primitive Data Types     28
Introducing the Demo Function     29
Creating a Managed Object     29
Backend SQL Visibility     31
Fetching Managed Objects     34
     Sorting Fetch Requests     36
     Filtering Fetch Requests     36
     Fetch Request Templates     38
Deleting Managed Objects     41
Summary     41
Exercises     42
3   Managed Object Model Migration     43
Changing a Managed Object Model     43
Adding a Model Version     45
Lightweight Migration     47
Default Migration     50
Migration Manager     54
     Introducing MigrationVC.swift (Migration View Controller Code)     56
     Introducing CDMigration.swift (Core Data Migration Code)     59
Summary     71
Exercises     71
4   Managed Object Model Expansion     73
Relationships     73
Delete Rules     79
     Introducing CDOperation.swift (Core Data Operation)     80
     Delete Rule Testing     83
Entity Inheritance     87
Summary     89
Exercises     89
5   Table Views     91
Table View Basics     91
Core Data Table Views     93
Introducing CDTableViewController     93
     Expanding CDTableViewController     96
     DATASOURCE: UITableView     98
     DELEGATE: NSFetchedResultsController     99
     CDTableViewController Subclasses     101
Enhancing PrepareTVC     105
     Preparing Test Data     107
     Deletion and Cell Selection for PrepareTVC     109
     Interaction for PrepareTVC     110
Introducing ShopTVC     114
     Cell Selection for ShopTVC     116
     INTERACTION for ShopTVC     116
Summary     118
Exercises     119
6   Views     121
View Basics     121
The Target View Hierarchy     122
Introducing ItemVC     123
     Keeping Reference to a Selected Item     123
     Passing a Selected Item to ItemVC     124
     Configuring the Scroll View and Text Fields     125
     Implementing ItemVC     129
     DELEGATE: UITextField     130
     The VIEW Section     131
     Adding Functionality to NSManagedObject Subclasses     133
Units, Home Locations, and Shop Locations     136
     Adding and Editing Units     138
     Implementing UnitsTVC     141
     Implementing UnitVC     143
     Segueing from UnitsTVC to UnitVC     145
     Adding and Editing Home or Shop Locations     146
     Configuring the Home Location Views     147
     Configuring the Shop Location Views     148
Summary     150
Exercises     150
7   Picker Views     151
Picker View Basics     151
Introducing CDPickerTextField     152
Introducing UnitPickerTF     157
     Creating the Unit Picker     159
     Connecting the Unit Picker     160
     Configuring ItemVC for the Unit Picker     161
Introducing LocationAtHomePickerTF     165
Introducing LocationAtShopPickerTF     167
Using the Location Pickers     168
     Connecting the Location Pickers     169
     Configuring ItemVC for the Location Pickers     170
Picker-Avoiding Text Field     173
Summary     176
Exercises     176
8   Preloading Data     177
Including Default Data     177
Indicating Whether an Import Is Required     178
Importing from XML     182
Creating an Import Context     184
Preventing Duplicate Default Data     185
Triggering a Default Data Import     186
Finding or Creating Managed Objects     188
Mapping XML Data to Entity Attributes     192
Importing from a Persistent Store     195
     Using the Default Data Store as the Initial Store     196
Summary     199
Exercises     200
9   Deep Copy     201
The Deep Copy Process     201
Configuring a Source Stack     204
     Configuring the Source Coordinator     204
     Configuring the Source Context     205
     Configuring the Source Store     205
Enhancing CDImporter     206
     Identifying Unique Attributes     207
     Object Info     207
     Copying a Unique Object     208
     Establishing a To-One Relationship     210
     Establishing a To-Many Relationship     211
     Establishing an Ordered To-Many Relationship     212
     Copying Relationships     213
     Deep Copy Entities     215
Triggering a Deep Copy     216
Summary     219
Exercises     219
10   Performance     221
Identifying Performance Issues     221
Implementing the Camera     222
     Implementing the Image Picker Controller Delegates     224
Generating Test Data     228
     Merge Policies     230
Measuring Performance with SQLDebug     232
Measuring Performance with Instruments     233
Improving Performance     236
     Model Optimization     238
     Handling Large Objects     239
Cleaning Up     246
Summary     246
Exercises     247
11   Background Processing     249
Implementing Background Save     249
Configuring an Import Context Parent     253
Faulting Objects     254
Generating Thumbnails     257
Summary     261
Exercises     261
12   Search     265
Updating CDTableViewController     266
Updating PrepareTVC     268
Search Optimization     269
Summary     270
Exercises     270
13   iCloud     271
iCloud Basics     271
Enabling iCloud     273
Updating CDHelper for iCloud     274
     Adding an iCloud Store     275
     Handling iCloud Notifications     277
The Debug Navigator     280
Summary     281
Exercises     282
14   Taming iCloud     283
De-Duplication     283
     Identifying Duplicates     284
     Deleting Duplicates     286
     Triggering De-Duplication     291
Seeding     292
     Preparing Seed Variables     293
     Adding Seed Helper Functions     295
Developing with a Clean Slate     300
Configurations     302
Summary     303
Exercises     303
15   CloudKit Sync: Uploading Objects     307
Introducing CloudKit     307
CloudKit Database Synchronization Limitations     309
Introducing CDCloudSync     309
Public Data Groups     311
Cache Status     316
CloudKit Building Blocks     320
Uploading New Records and Relationships     325
Adding Synchronization Logic     327
Preparing the Managed Object Model for Sync     331
Summary     335
Exercises     335
16   CloudKit Sync: Downloading Changes and Handling Deletions     337
CloudKit Building Blocks (Continued)     337
Change Synchronization     342
Deletion Synchronization     350
Quality Assurance     354
Testing the Network     357
Updating Synchronization Logic     359
Adding CDCloudSync to Your Own Applications     361
Summary     367
Exercises     367
Thank You!     367
A   Preparing the Groceries Application     369
New Xcode Project     369
Storyboard Design     370
App Icons and Launch Images     373
Introducing GenericVC     374
B   Finalizing the Groceries Application     377
New Features     377
Photo Library and Photo Deletion Support     378
Favorites     380
Icon Badge     384
Location De-Duplication Logic     385

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020