Donny Wals
  • Home
  • The Blog
  • The Newsletter
  • Speaking
  • Books
    • Practical Core Data
    • Practical Combine

Core Data

Preventing unwanted fetches when using NSFetchedResultsController and fetchBatchSize

This article covers a topic that is extensively covered in my Practical Core Data book. This book is intended to help you learn Core Data from scratch using modern techniques and every chapter features sample apps in SwiftUI as well as UIKit whenever this is relevant. When you use Core Read more…

By donnywals, 3 months ago

Observing the result of saving a background managed object context with Combine

I love posts where I get to put write about two of my favorite frameworks at the moment; Combine and Core Data. When you’re working with Core Data, it’s common to perform save operations asynchronously using a background context. You could even perform an asynchronous save on the main managed Read more…

By donnywals, 5 months5 months ago

Responding to changes in a managed object context

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 Read more…

By donnywals, 5 months5 months ago

Observing changes to managed objects across contexts with Combine

A common pattern in Core Data is to fetch objects and show them in your UI using one managed object context, and then use another context to update, insert or delete managed objects. There are several ways for you to update your UI in response to these changes, for example Read more…

By donnywals, 6 months6 months ago

Understanding the differences between your Core Data model and managed objects

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 Read more…

By donnywals, 7 months ago

Implementing a one-way sync strategy with Core Data, URLSession and Combine

A common use of a Core Data store is to cache data from a remote resource locally to support offline functionality of an app. There are multiple ways to implement a caching mechanism and many of them don’t involve Core Data. For example, you could simply fetch a JSON file Read more…

By donnywals, 8 months ago

Fetching objects from Core Data in a SwiftUI project

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 Read more…

By donnywals, 9 months8 months ago

Using Codable with Core Data and NSManagedObject

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 Read more…

By donnywals, 9 months3 weeks ago

Setting up a Core Data store for unit tests

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 Read more…

By donnywals, 9 months9 months ago

Using Core Data with SwiftUI 2.0 and Xcode 12

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 Read more…

By donnywals, 9 months7 months ago

Posts navigation

1 2 Next
Categories
  • Books
  • Home
  • The Blog
  • The Newsletter
  • Speaking
Hestia | Developed by ThemeIsle