35 Results for: "codable"

Working with dates and Codable in Swift

Updated on: April 23, 2024

When you’re decoding JSON, you’ll run into situations where you’ll have to decode dates every once in a while. Most commonly you’ll probably be dealing with dates that conform to the ISO-8601 standard but there’s also a good chance that you’ll have to deal with different date formats. In this post, we’ll take a look […]

Read post

Making your SwiftData models Codable

Updated on: April 23, 2024

In a previous post, I explained how you can make your NSManagedObject subclasses codable. This was a somewhat tedious process that involves a bunch of manual work. Specifically because the most convenient way I’ve found wasn’t all that convenient. It’s easy to forget to set your managed object context on your decoder’s user info dictionary […]

Read post

Customizing how Codable objects map to JSON data

Updated on: March 12, 2024

In the introductory post for this series you learned the basics of decoding and encoding JSON to and from your Swift structs. In that post, you learned that your JSON object is essentially a dictionary, and that the JSON’s dictionary key’s are mapped to your Swift object’s properties. When encoding, your Swift properties are used […]

Read post

JSON parsing in Swift explained using Codable

Updated on: July 4, 2025

Virtually every modern application needs some way to retrieve, and use, data from a remote source. This data is commonly fetched by making a network request to a webserver that returns data in a JSON format. When you’re working with Javascript, this JSON data can be easily decoded into a Javascript object. Javascript doesn’t have […]

Read post

Flattening a nested JSON response into a single struct with Codable

Updated on: February 19, 2024

Often, you’ll want you Swift models to resemble JSON that’s produced by an external source, like a server, as closely as possible. However, there are times when the JSON you receive is nested several levels deep and you might not consider this appropriate or needed for your application. Or maybe you’re only interested in a […]

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

Creating type-safe identifiers for your Codable models

Updated on: April 5, 2021

Note: After publishing this article, it has been brought to my attention that the folks from @pointfreeco have a very similar solution for the problems I outline in this post. It’s called tagged and implements the same features I cover in this post with several useful extensions. If you like this post and plan to […]

Read post

What is Approachable Concurrency in Xcode 26?

Published on: July 9, 2025

Xcode 26 allows developers to opt-in to several of Swift 6.2’s features that will make concurrency more approachable to developers through a compiler setting called “Approachable Concurrency” or SWIFT_APPROACHABLE_CONCURRENCY. In this post, we’ll take a look at how to enable approachable concurrency, and which compiler settings are affected by it. How to enable approachable concurrency […]

Read post

Expand your learning with my books

Practical Combine header image

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

  • Thirteen chapters worth of content.
  • Playgrounds and sample projects that use the code shown in the chapters.
  • Free updates for future iOS versions.

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

Learn more