Practical Core Data: A Modern Guide To The Core Data Framework Donny Wals Instant Download
Practical Core Data: A Modern Guide To The Core Data Framework Donny Wals Instant Download
https://ebookmeta.com/product/practical-core-data-a-modern-guide-
to-the-core-data-framework-donny-wals/
https://ebookmeta.com/product/core-data-mastery-in-swiftui-mark-
moeykens/
https://ebookmeta.com/product/pro-entity-framework-core-2-for-
asp-net-core-mvc-1st-edition-adam-freeman/
https://ebookmeta.com/product/practical-entity-framework-
core-6-database-access-for-enterprise-applications-brian-l-
gorman/
https://ebookmeta.com/product/into-ones-own-from-youth-to-
adulthood-in-the-united-states-1920-1975-john-modell/
Financial Reckoning Day: Memes, Manias, Booms & Busts
... Investing In the 21st Century 3rd Edition Addison
Wiggin
https://ebookmeta.com/product/financial-reckoning-day-memes-
manias-booms-busts-investing-in-the-21st-century-3rd-edition-
addison-wiggin/
https://ebookmeta.com/product/a-foreboding-of-petrels-birder-
murder-mystery-7-1st-edition-steve-burrows/
https://ebookmeta.com/product/a-federal-perspective-on-the-
abkhaz-georgian-conflict-from-intractability-to-pacification-1st-
edition-romina-gurashi/
https://ebookmeta.com/product/breaking-waves-1st-edition-barry-
litherland/
https://ebookmeta.com/product/a-marriage-made-in-heaven-the-
sexual-politics-of-hebrew-and-yiddish-naomi-seidman/
The Alpha Female Wolf: The Fierce Legacy of
Yellowstone's 06 (The Alpha Wolves of Yellowstone)
First Edition Rick Mcintyre
https://ebookmeta.com/product/the-alpha-female-wolf-the-fierce-
legacy-of-yellowstones-06-the-alpha-wolves-of-yellowstone-first-
edition-rick-mcintyre/
Contents
Practical Core Data: A modern guide to the Core Data framework 6
Chapter Overview 8
Chapter 1 - Taking your first steps with Core Data . . . . . . . . . . . . . . . . . . . 8
Chapter 2 - Understanding Core Data’s building blocks . . . . . . . . . . . . . . . . 8
Chapter 3 - Defining entities using the model editor . . . . . . . . . . . . . . . . . 8
Chapter 4 - Fetching and displaying data from a Core Data store . . . . . . . . . . . 9
Chapter 5 - Using Core Data in a multithreaded environment . . . . . . . . . . . . 9
Chapter 6 - Sharing a Core Data store with apps and extensions . . . . . . . . . . . 10
Chapter 7 - Synchronizing your store with a remote data source . . . . . . . . . . . 10
Chapter 8 - Synchronizing your store with CloudKit . . . . . . . . . . . . . . . . . 10
Chapter 9 - Updating your data model and performing migrations . . . . . . . . . 11
Chapter 10 - Debugging and profiling your Core Data implementation . . . . . . . 11
Chapter 11 - Using Core Data in your unit tests . . . . . . . . . . . . . . . . . . . . 11
Chapter 12 - Where to go from here? . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Donny Wals 3
Practical Core Data
Chapter 6 - Sharing a Core Data store with apps and extensions 160
Setting your app up for data sharing with App Groups . . . . . . . . . . . . . . . . 160
Enabling App Groups for your app or extension . . . . . . . . . . . . . . . . . 161
Configuring your persistent container for data sharing . . . . . . . . . . . . . 162
Migrating an existing SQLite store to your App Group . . . . . . . . . . . . . . 164
Efficiently using a shared Core Data store . . . . . . . . . . . . . . . . . . . . . . . 169
Understanding why batch requests don’t trigger notifications . . . . . . . . . 169
Getting started with persistent history tracking . . . . . . . . . . . . . . . . . 173
Using persistent history tracking with multiple apps and extensions . . . . . 182
In Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Donny Wals 4
Practical Core Data
Donny Wals 5
Practical Core Data
Donny Wals 6
Practical Core Data
In this book, I hope to show you that Core Data isn’t as rough as it used to be. In fact, I find
Core Data quite pleasant to work with nowadays, and I hope that my enthusiasm will spark
some enthusiasm in you as well. Of course, Core Data isn’t always easy to work with. That’s
another part of why I wrote this book. I want to provide you with a solid foundation that helps
you understand, and use, Core Data in modern applications. Both in SwiftUI, and in UIKit.
This book has been a long time in the making, and if it wasn’t for my wife Dorien, it probably
would have taken me even longer. Her ongoing support and understanding throughout the
writing process has been amazing. I owe her a bunch of date-nights to make up for all the
time I’ve spent cooped up in my office.
I want to thank everybody that has provided feedback on the pre-release version of this book
that I released a few weeks before releasing the full book. I have received tons of input and
it’s been incredibly useful. I especially want to thank David DeWolfe for providing me with an
extensive list of corrections and improvements with regards to spelling on both the pre-release
and the final version of the book. I’m truly grateful for the work you’ve put in to help me out,
David.
And of course, I want to extend a big thanks to you, the reader. Without you, this book wouldn’t
exist at all. So thank you for buying this book and supporting my work. It means a ton to
me.
If you find any mistakes, errors or inconsistencies in this book don’t hesitate to send me an
email at [email protected]. I’ve put a lot of care and attention into this book but
I’m only human and I need your feedback to make this book the best resource it can be. Make
sure you also reach out if you have any questions that aren’t answered by this book even
though you hoped it would so I can answer your questions directly, or possibly update the
book if needed.
Cheers,
Donny
Donny Wals 7
Practical Core Data
Chapter Overview
Donny Wals 8
Practical Core Data
This chapter will provide an in-depth look at the model editor. You will learn about entities,
relationships, fetch requests, transient properties, constraints, model versions, and much
more. By the end of this chapter, you will have a solid understanding of the model editor and
how you can use it to define your data models.
Donny Wals 9
Practical Core Data
Donny Wals 10
Practical Core Data
this chapter, you will learn how you can leverage this feature, and how you can write data to
CloudKit’s private and public storage.
Donny Wals 11
Practical Core Data
Data store in your unit tests. This will allow you to write your unit tests in isolation without
interfering with each other by setting up a separate, temporary, store for each unit test.
Donny Wals 12
Practical Core Data
By the end of this chapter, you will have learned a lot of Core Data basics, and you will have a
solid foundation to build upon in the rest of this book.
1. It’s good to see that there’s no magic involved in adding Core Data to a project.
2. The differences between the generated code in SwiftUI and UIKit projects can be con-
fusing and would make it much harder for me to write this chapter.
Donny Wals 13
Practical Core Data
I’d like to expand on my second point a little bit because I can already hear you think “Donny,
you’re supposed to explain the confusing parts. Not hide them.”
You’re right. I wrote this book to take away a lot of the confusion that surrounds Core Data.
Believe me when I say that adding Core Data to a project by hand is a great way to reduce
confusion. You will understand exactly what’s going on in the generated code for both SwiftUI
and UIKit since the code that Xcode generates for each is nothing more than a different
implementation of the same principle. The approach that I’ll show you in this chapter is very
similar to the one that’s used in Xcode’s SwiftUI template and can be used in a UIKit project
without problems.
To follow along with this chapter, you can either create a new Xcode project yourself, or you
can take a look at the code in the Chapter 1 folder in the book’s code bundle. The code in the
bundle is the finished project so for typing along I would recommend creating a fresh Xcode
project from scratch.
Create a new project and make sure the use Core Data checkbox is unchecked. We’re not
going to add unit tests to this project so you can uncheck the unit testing checkbox as well. For
your user interface, you can use either SwiftUI or a Storyboard, it doesn’t matter much since
I’ll go over both options in this chapter. I recommend that you use whichever UI framework
you’re comfortable with (or pick the one you want to learn more about).
Donny Wals 14
Practical Core Data
Note: Throughout this book, I assume that you have at least basic knowledge of Xcode,
Swift, and iOS development, so I won’t explain everything every step of the way unless
it’s directly related to Core Data, or if I think the topic is obscure or advanced enough to
warrant some extra explanation.
To add Core Data to your newly created project, you need to create a new Core Data model
file. You can do this through the New File menu (File -> New -> File or cmd + N). Select the
Data Model file type from the list of files and click Create:
Donny Wals 15
Another Random Scribd Document
with Unrelated Content
XVIII LUKU.
Pihalle tultuani tuli minulle lohdutus. Holvin alla oli tuo pieni
mykkä. Hän tunsi minut heti ja tahtoi rientää luokseni, mutta vartijan
vaimo, en tiedä mistä syystä, kaappasi häntä kauluksesta kiinni ja
ajoi hänet sisään. Olin pahoillani siitä, ett'en saanut häntä syleillä,
mutta sen ohessa minua ilahutti hänen yrityksensä tulla luokseni.
Suloiselta tuntuu olla rakastettu!
— Aivan niin. —
— Ovat.
— Olette siis…
En uskonut kaikkea, mitä hän sanoi. Mutta että hän täällä oli kuin
haudattuna, se oli semmoinen totuus, joka herätti minussa
myötätuntoisuutta.
Pikkutorin (Piazzettan) yli oli mentävä… tällä torilla oli viime kerran
muuan kerjäläinen minulle lausunut seuraavat kummalliset sanat: —
Näkyy, hyvä herra, että olette muukalainen; ihmettä, kuinka te ja
muut muukalaiset ihailette tätä toria; minun mielestäni se on
onnettomuuden kotopaikka, enkä minä tule tänne muutoin kuin
pakosta.