SwiftData by Example
About 12 min
SwiftData by Example 관련
HACKING WITH SWIFT
SwiftData by Example
SwiftData by Example is the world's largest collection of SwiftData examples, tips, and techniques to help you build apps, solve problems, and understand how SwiftData really works.
Introduction
A brief explanation of the basics of SwiftData
What is SwiftData? | SwiftData by Example
What is SwiftData?
SwiftData vs Core Data | SwiftData by Example
SwiftData vs Core Data
Should you learn SwiftData, Core Data, or both? | SwiftData by Example
Should you learn SwiftData, Core Data, or both?
Frequently asked questions about SwiftData | SwiftData by Example
Frequently asked questions about SwiftData
How to follow this quick start guide | SwiftData by Example
How to follow this quick start guide
Migrating from Core Data to SwiftData | SwiftData by Example
Migrating from Core Data to SwiftData
Dedication | SwiftData by Example
Dedication
Building a complete project
Learn SwiftData hands-on with a real app project
SwiftData tutorial: Building a complete project | SwiftData by Example
SwiftData tutorial: Building a complete project
Defining a data model with SwiftData | SwiftData by Example
Defining a data model with SwiftData
Querying SwiftData objects in SwiftUI | SwiftData by Example
Querying SwiftData objects in SwiftUI
Creating, editing, and deleting model objects | SwiftData by Example
Creating, editing, and deleting model objects
Sorting query results | SwiftData by Example
Sorting query results
Filtering the results from a SwiftData query | SwiftData by Example
Filtering the results from a SwiftData query
Working with relationships | SwiftData by Example
Working with relationships
Wrap up: our SwiftData project is complete | SwiftData by Example
Wrap up: our SwiftData project is complete
Containers and context
Configuring your SwiftData app for success.
What's the difference between ModelContainer, ModelContext, and ModelConfiguration? | SwiftData by Example
What's the difference between ModelContainer, ModelContext, and ModelConfiguration?
How to configure a custom ModelContainer using ModelConfiguration | SwiftData by Example
How to configure a custom ModelContainer using ModelConfiguration
How to add multiple configurations to a ModelContainer | SwiftData by Example
How to add multiple configurations to a ModelContainer
How to change SwiftData’s underlying storage filename | SwiftData by Example
How to change SwiftData’s underlying storage filename
When does SwiftData autosave data? | SwiftData by Example
When does SwiftData autosave data?
How to enable or disable autosave for a ModelContext | SwiftData by Example
How to enable or disable autosave for a ModelContext
Defining your data model
Storage, data types, attributes, and more.
How to define SwiftData models using the @Model macro | SwiftData by Example
How to define SwiftData models using the @Model macro
Why are SwiftData models created as classes? | SwiftData by Example
Why are SwiftData models created as classes?
What kind of data can be a SwiftData property? | SwiftData by Example
What kind of data can be a SwiftData property?
Using structs and enums in SwiftData models | SwiftData by Example
Using structs and enums in SwiftData models
How to make unique attributes in a SwiftData model | SwiftData by Example
How to make unique attributes in a SwiftData model
How to make transient attributes in a SwiftData model | SwiftData by Example
How to make transient attributes in a SwiftData model
How to store SwiftData attributes in an external file | SwiftData by Example
How to store SwiftData attributes in an external file
How to index SwiftData objects in Spotlight | SwiftData by Example
How to index SwiftData objects in Spotlight
How to encrypt SwiftData | SwiftData by Example
How to encrypt SwiftData
How to create derived attributes with SwiftData | SwiftData by Example
How to create derived attributes with SwiftData
How to index SwiftData properties for faster searching | SwiftData by Example
How to index SwiftData properties for faster searching
Creating relationships
Creating and managing links between data
Inferred vs explicit relationships | SwiftData by Example
Inferred vs explicit relationships
How to create one-to-one relationships | SwiftData by Example
How to create one-to-one relationships
How to create one-to-many relationships | SwiftData by Example
How to create one-to-many relationships
How to create many-to-many relationships | SwiftData by Example
How to create many-to-many relationships
How to create cascade deletes using relationships | SwiftData by Example
How to create cascade deletes using relationships
How to add minimum and maximum constraints to relationships | SwiftData by Example
How to add minimum and maximum constraints to relationships
Working with data
Creating, loading, saving, and searching for objects.
How to find a SwiftData object by its identifier | SwiftData by Example
How to find a SwiftData object by its identifier
How to save a SwiftData object | SwiftData by Example
How to save a SwiftData object
How to delete a SwiftData object | SwiftData by Example
How to delete a SwiftData object
How to create a custom FetchDescriptor | SwiftData by Example
How to create a custom FetchDescriptor
How to filter SwiftData results with predicates | SwiftData by Example
How to filter SwiftData results with predicates
How to sort SwiftData queries using key paths or SortDescriptor | SwiftData by Example
How to sort SwiftData queries using key paths or SortDescriptor
How to get natural string sorting for SwiftData queries | SwiftData by Example
How to get natural string sorting for SwiftData queries
How to count results without loading them | SwiftData by Example
How to count results without loading them
How to delete all instances of a particular model | SwiftData by Example
How to delete all instances of a particular model
How to create a background context | SwiftData by Example
How to create a background context
How to add support for undo and redo | SwiftData by Example
How to add support for undo and redo
How to completely reset a SwiftData ModelContainer | SwiftData by Example
How to completely reset a SwiftData ModelContainer
How to enumerate a fetch request to handle lots of data efficiently | SwiftData by Example
How to enumerate a fetch request to handle lots of data efficiently
How to merge two model contexts | SwiftData by Example
How to merge two model contexts
How to make SwiftData models conform to Codable | SwiftData by Example
How to make SwiftData models conform to Codable
How to rollback changes without saving | SwiftData by Example
How to rollback changes without saving
Handling migration
How to update your models without risk.
Lightweight vs complex migrations | SwiftData by Example
Lightweight vs complex migrations
How to rename properties without losing data | SwiftData by Example
How to rename properties without losing data
How to create a complex migration using VersionedSchema | SwiftData by Example
How to create a complex migration using VersionedSchema
Building with SwiftData
Working with SwiftUI UIKit, widgets, and more.
How to connect SwiftData to SwiftUI | SwiftData by Example
How to connect SwiftData to SwiftUI
How to use @Query to read SwiftData objects from SwiftUI | SwiftData by Example
How to use @Query to read SwiftData objects from SwiftUI
How to dynamically change a query's sort order or predicate | SwiftData by Example
How to dynamically change a query's sort order or predicate
What's the difference between @Bindable and @Binding? | SwiftData by Example
What's the difference between @Bindable and @Binding?
How to animate changes to SwiftData queries | SwiftData by Example
How to animate changes to SwiftData queries
How to use SwiftData in SwiftUI previews | SwiftData by Example
How to use SwiftData in SwiftUI previews
How SwiftUI tracks changes in SwiftData objects | SwiftData by Example
How SwiftUI tracks changes in SwiftData objects
How to use SwiftData with UIKit | SwiftData by Example
How to use SwiftData with UIKit
How to migrate an app from Core Data to SwiftData | SwiftData by Example
How to migrate an app from Core Data to SwiftData
How to make Core Data and SwiftData coexist in the same app | SwiftData by Example
How to make Core Data and SwiftData coexist in the same app
How to create a document-based app with SwiftData | SwiftData by Example
How to create a document-based app with SwiftData
How to sync SwiftData with iCloud | SwiftData by Example
How to sync SwiftData with iCloud
How to stop SwiftData syncing with CloudKit | SwiftData by Example
How to stop SwiftData syncing with CloudKit
How to access a SwiftData container from widgets | SwiftData by Example
How to access a SwiftData container from widgets
Architecture
Structuring SwiftData code in a flexible, maintainable way.
How to use MVVM to separate SwiftData from your views | SwiftData by Example
How to use MVVM to separate SwiftData from your views
How to discard changes to a SwiftData object | SwiftData by Example
How to discard changes to a SwiftData object
How to pre-populate an app with an existing SwiftData database | SwiftData by Example
How to pre-populate an app with an existing SwiftData database
How to pre-load an app with JSON | SwiftData by Example
How to pre-load an app with JSON
How to transfer an object between a background context and the main context | SwiftData by Example
How to transfer an object between a background context and the main context
How SwiftData works with Swift concurrency | SwiftData by Example
How SwiftData works with Swift concurrency
How to batch insert large amounts of data efficiently | SwiftData by Example
How to batch insert large amounts of data efficiently
How to write unit tests for your SwiftData code | SwiftData by Example
How to write unit tests for your SwiftData code
How to write UI tests for your SwiftData code | SwiftData by Example
How to write UI tests for your SwiftData code
How to optimize the performance of your SwiftData apps | SwiftData by Example
How to optimize the performance of your SwiftData apps
How to use SwiftData to store singletons | SwiftData by Example
How to use SwiftData to store singletons
Solving problems
Common problems. Solved.
How to read the list of objects that have been inserted, edited, or deleted | SwiftData by Example
How to read the list of objects that have been inserted, edited, or deleted
How to check whether a SwiftData model object has been deleted | SwiftData by Example
How to check whether a SwiftData model object has been deleted
Using launch arguments to debug SwiftData and Core Data | SwiftData by Example
Using launch arguments to debug SwiftData and Core Data
How to read the contents of a SwiftData database store | SwiftData by Example
How to read the contents of a SwiftData database store
Common SwiftData errors and their solutions | SwiftData by Example
Common SwiftData errors and their solutions