Getting Started with SwiftData
During Apple’s World Wide Developer Conference (WWDC) in 2023, they introduced SwiftData, an all-new framework for saving app data. Previously, developers had to use an editor to create data models, but SwiftData allows developers to describe data models and manipulate model instances using regular Swift code. Features such as relationship management, undo/redo support, iCloud synchronization, and more are provided automatically. In 2024, Apple added new APIs that enable developers to build custom data stores, work with transaction history, model indices and compound uniqueness constraints, and more.
In this chapter, you’re going to modify the JRNL app that you completed in Chapter 16, Passing Data between View Controllers, to save journal entries using SwiftData. This means that when you add new journal entries to the app, they will reappear the next time the app is launched.
First, you’ll learn about SwiftData and its components...