Learn more about Core Data

Responding to changes in a managed object context

Published on: November 23, 2020

Working with multiple managed object contexts will often involve responding to changes that were made in one context to update another context. You might not even want to update another context but reload your UI or perform some other kind of update. Maybe you want to do this when a specific context updates, or maybe […]

Read post

Understanding the differences between your Core Data model and managed objects

Published on: October 5, 2020

You may have noticed that when Xcode generates your NSManagedObject classes based on your Core Data model file, most of your managed object’s properties are optional. Even if you’ve made them required in the model editor, Xcode will generate a managed object where most properties are optional. In this article we’ll explore this phenomenon, and […]

Read post

Fetching objects from Core Data in a SwiftUI project

Updated on: August 18, 2020

When you’ve added Core Data to your SwiftUI project and you have some data stored in your database, the next hurdle is to somehow fetch that data from your Core Data store and present it to the user. In this week’s post, I will present two different ways that you can use to retrieve data […]

Read post

Using Codable with Core Data and NSManagedObject

Updated on: April 5, 2021

If you’ve ever wanted to decode a bunch of JSON data into NSManagedObject instances you’ve probably noticed that this isn’t a straightforward exercise. With plain structs, you can conform your struct to Codable and you convert the struct from and to JSON data automatically. For an NSManagedObject subclass it’s not that easy. If your Core […]

Read post

Setting up a Core Data store for unit tests

Updated on: August 4, 2020

Unit testing is an important skill in the toolbox of any engineer. Knowing how to write a reliable, robust test suite helps you write reliable and robust code. If you’ve followed my introduction to unit testing part one and part two, or if you’re experienced with unit testing you know that your tests should run […]

Read post

Using Core Data with SwiftUI 2.0 and Xcode 12

Updated on: September 30, 2020

In Xcode 12 you can create projects that no longer use an AppDelegate and SceneDelegate to manage the application lifecycle. Instead, we can use Swift’s new @main annotation to turn a struct that conforms to the App protocol into the main entry point for our applications. When you create a new project in Xcode 12, […]

Read post

Expand your learning with my books

Practical Core Data header image

Learn everything you need to know about Core Data and how you can use it in your projects with Practical Core Data. It contains:

  • Twelve chapters worth of content.
  • Sample projects for both SwiftUI and UIKit.
  • Free updates for future iOS versions.

The book is available as a digital download for just $39.99!

Learn more