Article may be outdated

This article is 85 days old. Some details may have changed since publication.

infoq.com·3 min read·hard

SwiftData Enhances Queries, Adds Support for External Types and Data Store Observation

S
Sergio De Simone
SwiftData Enhances Queries, Adds Support for External Types and Data Store Observation
✦AI Summary

The latest update to SwiftData introduces support for Codable types, allowing developers to integrate third-party data models more easily. It also adds a sectionBy parameter for queries and a ResultObserver for improved data monitoring.

Why it matters

These updates improve the developer experience for iOS and macOS app development, simplifying complex data management tasks.

✦Dive DeeperCreate a free account to unlock

InfoQ Homepage News SwiftData Enhances Queries, Adds Support for External Types and Data Store Observation

Codable attributes solve a limitation in SwiftData when integrating custom or third-party types into a model. Since you do not control a third-party reference type, you cannot mark it with @Model . As a result, it cannot be included directly into a model, because SwiftData is unable to generate a schema for it.

With the new release, though, a third-party type can work seamlessly with SwiftData as long as it conforms to the Codable protocol. In the following example, ExLocation is a value type that we do not control, originating either from the iOS SDK or a third-party library:

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technology
✦

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in