swift · note · architecture · state

What's New in SwiftData

Published September 3, 2026 · 2 min read · intermediate

Context

SwiftData only becomes useful in a SwiftUI app when the model boundary stays clear. If the storage layer leaks into every view, the feature gets harder to reason about, even if the API looks modern.

The snippet

@Model
final class DraftProfile {
    var name: String
    var city: String

    init(name: String, city: String) {
        self.name = name
        self.city = city
    }
}

Why this works

SwiftData is strongest when it helps you keep data at the right boundary. That usually means the screen or feature owns the model flow, while child views borrow editing access.

Use it when:

  • the feature already has a clear owner for the model
  • you want a persistent source of truth for the screen
  • previews and tests can inject a lightweight store or sample model

Avoid it when:

  • you only need a tiny local editing state
  • the persistence layer would make the view harder to extract
  • you start reaching into the database from unrelated child views

Takeaway: SwiftData is a storage tool, not a reason to blur ownership.

Next steps