Statistics
14
Views
0
Downloads
0
Donations
Support
Share
Uploader

高宏飞

Shared on 2026-03-08

AuthorAaron Douglas, Matthew Morey and Pietro Rea

No description

Tags
No tags
Publisher: Razeware LLC.
Publish Year: 2020
Language: 英文
File Format: PDF
File Size: 31.3 MB
Support Statistics
¥.00 · 0times
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

(This page has no text content)
Core Data by Tutorials Aaron Douglas, Matthew Morey and Pietro Rea Copyright ©2020 Razeware LLC. Notice of Rights All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner. Notice of Liability This book and all corresponding materials (such as source code) are provided on an “as is” basis, without warranty of any kind, express of implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of other dealing in the software. Trademarks All trademarks and registered trademarks appearing in this book are the property of their own respective owners. Core Data by Tutorials raywenderlich.com 2
Dedications “To my husband, Mike, who puts up with all my weird quirks and supports all the things I do.” — Aaron Douglas “To my amazing wife Tricia and my parents — Thanks for always supporting me.” — Matthew Morey “To my wonderful wife Emily, my daughter Rose, and my parents. Thank you for always supporting me every step of the way.” — Pietro Rea Core Data by Tutorials raywenderlich.com 3
About the Authors Aaron Douglas was that kid taking apart the mechanical and electrical appliances at five years of age to see how they worked. He never grew out of that core interest - to know how things work. He took an early interest in computer programming, figuring out how to get past security to be able to play games on his dad’s computer. He’s still that feisty nerd, but at least now he gets paid to do it. Aaron works for Automattic (WordPress.com, WooCommerce, Tumblr, Simplenote) as a Mobile Lead primarily on the WooCommerce mobile apps. Find Aaron on Twitter as @astralbodies and on his blog at https://aaron.blog. Matthew Morey is an engineer, developer, hacker, creator, and tinkerer. As an active member of the mobile community and head of technology at Valtech he has led numerous successful mobile projects worldwide. He’s the creator of Buoy Explorer, a marine conditions app for water sports enthusiast, and Wrist Presenter, an app that lets you control presentations wirelessly with your smart watch. When not developing apps he enjoys traveling, snowboarding, and surfing. He blogs about technology and business at matthewmorey.com. Pietro Rea is a senior software engineer at Upside Travel in Washington D.C. Pietro’s work has been featured in the App Store across several categories: media, e-commerce, lifestyle and more. Having worked at Fortune 500 companies and venture-backed startups, Pietro has a passion for building apps users can’t live without. You can find Pietro on Twitter as @pietrorea. About the Editors Darren Ferguson is the technical editor for this book. He is an experienced software developer and works for M.C. Dean, Inc, a systems integration provider from North Virginia. When he’s not coding, you’ll find him enjoying EPL Football, traveling as much as possible and spending time with his wife and daughter. Find Darren on Twitter as @darren102. Core Data by Tutorials raywenderlich.com 4
Rich Turton is the final pass editor of this book. Rich is an iOS developer for MartianCraft and long-time contributor to raywenderlich.com. When he’s not in front of a computer he is usually trying to play the piano, trying to make fancy cocktails, or trying to play elaborate Lego games with his daughters. Sometimes all at the same time. Sandra Grauschopf is an editor of this book. Sandra has over 20 years’ experience as a writer, editor, copy editor, and content manager. She’s been editing tutorials at raywenderlich.com since 2018. She loves to travel and explore new places, always with a trusty book close at hand. About the Artist Vicki Wenderlich is the designer and artist of the cover of this book. She is Ray’s wife and business partner. She is a digital artist who creates illustrations, game art and a lot of other art or design work for the tutorials and books on raywenderlich.com. When she’s not making art, she loves hiking, a good glass of wine and attempting to create the perfect cheese plate. Core Data by Tutorials raywenderlich.com 5
Table of Contents: Overview Book License 11............................................................................................. Before You Begin 12................................................................ What You Need 13........................................................................................ Book Source Code & Forums 14............................................................. About the Cover 15...................................................................................... Acknowledgements 16............................................................................... Introduction 17.............................................................................................. Core Data by Tutorials 21...................................................... Chapter 1: Your First Core Data App 22.............................................. Chapter 2: NSManagedObject Subclasses 43................................... Chapter 3: The Core Data Stack 74....................................................... Chapter 4: Intermediate Fetching 97.................................................... Chapter 5: NSFetchedResults Controller 133.................................. Chapter 6: Versioning & Migration 169............................................... Chapter 7: Unit Testing 212...................................................................... Chapter 8: Measuring & Boosting Performance 233......... Chapter 9: Multiple Managed Object Contexts 267.......... Chapter 10: NSPersistentCloudKit Container 288........................ Conclusion 313.............................................................................................. Core Data by Tutorials raywenderlich.com 6
Table of Contents: Extended Book License 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before You Begin 12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What You Need 13. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Book Source Code & Forums 14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About the Cover 15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Acknowledgements 16. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introduction 17. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Who this book is for 18. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . How to use this book 19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . What’s in store 19. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data by Tutorials 21. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 1: Your First Core Data App 22. . . . . . . . . . . . . . . . . . . . . . . . Getting started 23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modeling your data 32. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Saving to Core Data 35. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fetching from Core Data 40. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 42. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 2: NSManagedObject Subclasses 43. . . . . . . . . . . . . . . . . . Getting started 44. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modeling your data 46. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Storing non-standard data types in Core Data 50. . . . . . . . . . . . . . . . . . . . . . . Managed object subclasses 53. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Propagating a managed context 59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data validation in Core Data 68. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tying everything up 72. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data by Tutorials raywenderlich.com 7
Key points 73. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 3: The Core Data Stack 74. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 75. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rolling your own Core Data stack 76. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The managed object model 76. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The persistent store 77. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The persistent store coordinator 78. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The managed object context 78. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The persistent store container 79. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating your stack object 80. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modeling your data 82. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding managed object subclasses 86. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A walk down persistence lane 88. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting objects from Core Data 93. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 96. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 4: Intermediate Fetching 97. . . . . . . . . . . . . . . . . . . . . . . . . . . NSFetchRequest: the star of the show 98. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introducing the BubbleTea app 99. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stored fetch requests 102. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fetching different result types 106. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sorting fetched results 124. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asynchronous fetching 126. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Batch updates: no fetching required 129. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 132. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 5: NSFetchedResults Controller 133. . . . . . . . . . . . . . . . . . Introducing the World Cup app 134. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . It all begins with a fetch request… 136. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Grouping results into sections 145. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . “Cache” the ball 148. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Monitoring changes 150. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data by Tutorials raywenderlich.com 8
Inserting an underdog 156. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Diffable data sources 160. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 167. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 168. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 6: Versioning & Migration 169. . . . . . . . . . . . . . . . . . . . . . . . . When to migrate 170. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The migration process 170. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Types of migrations 171. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 172. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A lightweight migration 173. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inferred mapping models 176. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A manual migration 182. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A complex mapping model 190. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Migrating non-sequential versions 198. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A self-migrating stack 198. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Testing sequential migrations 209. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 211. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 7: Unit Testing 212. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting started 214. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data stack for testing 216. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Asynchronous tests 221. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tests first 224. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Validation and refactoring 228. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 232. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 232. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 8: Measuring & Boosting Performance 233. . . . . . . . . . . Getting started 234. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Measure, change, verify 235. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Fetching and performance 246. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 266. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data by Tutorials raywenderlich.com 9
Key points 266. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 9: Multiple Managed Object Contexts 267. . . . . . . . . . . . Getting started 268. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Introducing SurfJournal 268. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Doing work in the background 273. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Editing on a scratchpad 280. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Challenge 287. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 287. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Chapter 10: NSPersistentCloudKit Container 288. . . . . . . . . . . . . Getting started with Core Data and CloudKit 290. . . . . . . . . . . . . . . . . . . . . . . Introducing the Dog Doodies app 302. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Understanding CloudKit’s weaknesses 309. . . . . . . . . . . . . . . . . . . . . . . . . . . . . Key points 312. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Where to go from here? 312. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Conclusion 313. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Core Data by Tutorials raywenderlich.com 10
LBook License By purchasing Core Data by Tutorials, you have the following license: • You are allowed to use and/or modify the source code in Core Data by Tutorials in as many apps as you want, with no attribution required. • You are allowed to use and/or modify all art, images and designs that are included in Core Data by Tutorials in as many apps as you want, but must include this attribution line somewhere inside your app: “Artwork/images/designs: from Core Data by Tutorials book, available at http://www.raywenderlich.com.” • The source code included in Core Data by Tutorials is for your personal use only. You are NOT allowed to distribute or sell the source code in Core Data by Tutorials without prior authorization. • This book is for your personal use only. You are NOT allowed to sell this book without prior authorization or distribute it to friends, co-workers or students; they would need to purchase their own copies. All materials provided with this book are provided on an “as is” basis, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. All trademarks and registered trademarks appearing in this book are the property of their respective owners. raywenderlich.com 11
Before You Begin This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more. raywenderlich.com 12
iWhat You Need To follow along with the tutorials in this book, you’ll need the following: • A Mac running macOS Catalina or later. You’ll need this to be able to install the latest version of Xcode. • Xcode 12.0 or later. Xcode is the main development tool for iOS. You can download the latest version of Xcode from Apple’s developer site here: apple.co/ 2asi58y You can use the iOS 14 Simulator that comes with Xcode for all of the chapters. Once you have these items in place, you’ll be able to follow along with every chapter in this book. raywenderlich.com 13
iiBook Source Code & Forums Where to download the materials for this book The materials for this book can be cloned or downloaded from the GitHub book materials repository: • https://github.com/raywenderlich/cdt-materials/tree/editions/8.0 Forums We’ve also set up an official forum for the book at https://forums.raywenderlich.com/ c/books/core-data-by-tutorials. This is a great place to ask questions about the book or to submit any errors you may find. raywenderlich.com 14
iiiAbout the Cover Core Data by Tutorials Cover The North Pacific giant octopus is normally red in color but can quickly assume the color of its surroundings to blend in and hide from predators. Since it has no internal or external skeleton, it can squeeze into extremely small crevices. Core Data is a lot like that; it’s easier than ever to work it into your apps and let its various tentacles weave their way into your persistent data store! raywenderlich.com 15
ivAcknowledgements The Core Data by Tutorials team would also like to thank Saul Morrow for his work as one of the original authors of this book. raywenderlich.com 16
vIntroduction What is Core Data? You’ll hear a variety of answers to this question: It’s a database! It’s SQLite! It’s not a database! And so forth. Here’s the technical answer: Core Data is an object graph management and persistence framework in the macOS and iOS SDKs. That means Core Data can store and retrieve data, but it isn’t a relational database like MySQL or SQLite. Although it can use SQLite as the data store behind the scenes, you don’t think about Core Data in terms of tables and rows and primary keys. Imagine you’re writing an app to keep track of dining habits. You have a varied set of objects: restaurant objects, each with properties such as name and address; categories, to organize the restaurants; and visits, to log each visit to a restaurant. The object graph in memory might look something like this: raywenderlich.com 17
Object graph management means Core Data works with objects that you define, such as the ones in the diagram above. For example, each restaurant (represented by a red bubble) would have a property pointing back to the category object. It would also have a property holding the list of visits. Since UIKit is an object-oriented framework, you’re probably storing data in objects already. Core Data builds on this to keep track of the objects and their relationships to each other. You can imagine expanding the graph to include what the user ordered, ratings and so on. Persistence means the data is stored somewhere durable such as the device’s flash memory or “the cloud.” You point to the entire graph and just say “save.” When your app launches, you just say “load” and the entire object graph pops up in memory again, ready for use. That’s Core Data at work! Maybe your users eat out a lot and have thousands of restaurant visits — rest assured Core Data is smart about lazily loading objects and caching to optimize both memory usage and speed. Core Data has many other features aside from simply storing and fetching data: You can perform custom filtering with predicates, sort the data and and calculate statistics. You’ll learn all about these features and more in this book. We’ve updated all the chapters in this book for Swift 5.3, iOS 14 and Xcode 12. Who this book is for This book is for iOS developers who already know the basics of iOS and Swift, and want to learn Core Data. If you’re a complete beginner to iOS, we suggest you read through The iOS Apprentice first. That will give you a solid foundation in building iOS apps from the ground-up. If you know the basics of iOS development but are new to Swift, we suggest you read Swift Apprentice first. That book has a similar hands-on approach and takes you on a comprehensive tour through the Swift language. You can find both of these prerequisite books at our store: http:// store.raywenderlich.com Core Data by Tutorials Introduction raywenderlich.com 18
How to use this book This book will teach you the fundamentals of Core Data by means of hands-on tutorials. You’ll jump right into building a Core Data app in Chapter 1, as we think most people learn best by doing. We encourage you to type along with the instructions in the book. If you’re new to Core Data or want to review the basics, we suggest you start with Chapters 1–3. These chapters cover the fundamentals of Core Data and you’ll need the knowledge in them to understand the rest of the book. Otherwise, we suggest a pragmatic approach. Each chapter stands on its own, so you can pick and choose the chapters that interest you the most. What’s in store Here’s a quick summary of what you’ll find in each chapter: 1. Chapter 1, Your First Core Data App: You’ll click File ▸ New Project and write a Core Data app from scratch! This chapter covers the basics of setting up your data model and then adding and fetching records. 2. Chapter 2, NSManagedObject Subclasses: NSManagedObject is the base data storage class of your Core Data object graphs. This chapter will teach you how you customize your own managed object subclasses to store and validate data. 3. Chapter 3, The Core Data Stack: Under the hood, Core Data is made up of many parts working together. In this chapter, you’ll learn about how these parts fit together, and move away from the starter Xcode template to build your own customizable system. 4. Chapter 4, Intermediate Fetching: Your apps will fetch data all the time, and Core Data offers many options for getting the data to you efficiently. This chapter covers more advanced fetch requests, predicates, sorting and asynchronous fetching. 5. Chapter 5, NSFetchedResultsController: Table views are at the core of many iOS apps, and Apple wants to make Core Data play nicely with them! In this chapter, you’ll learn how NSFetchedResultsController can save you time and code when your table views are backed by data from Core Data. Core Data by Tutorials Introduction raywenderlich.com 19
6. Chapter 6, Versioning & Migration: As you update and enhance your app, its data model will almost certainly need to change. In this chapter, you’ll learn how to create multiple versions of your data model and then migrate your users forward so they can keep their existing data as they upgrade. 7. Chapter 7, Unit Tests: Testing is an important part of the development process, and you shouldn’t leave Core Data out of that! In this chapter, you’ll learn how to set up a separate test environment for Core Data and see examples of how to test your models. 8. Chapter 8, Measuring & Boosting Performance: No one ever complained that an app was too fast, so it’s important to be vigilant about tracking performance. In this chapter, you’ll learn how to measure your app’s performance with various Xcode tools and then pick up some tips for dealing with slow spots in your code. 9. Chapter 9, Multiple Managed Object Contexts: In this chapter, you’ll expand the usual Core Data stack to include multiple managed object contexts. You’ll learn how this can improve perceived performance and help make your app architecture less monolithic and more compartmentalized. 10. Chapter 10, NSPersistentCloudKitContainer: Your users may have multiple devices, and they’d love your app to run on them all, and for the data to be shared between them. In this chapter you will learn how to get iCloud-backed data synchronization (almost) for free using NSPersistentCloudKitContainer. Core Data by Tutorials Introduction raywenderlich.com 20