Skip to content

gahntpo/SnippetBox-SwiftData

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SnippetBox-SwiftData

This is a demo project that I made to test the new SwiftData framework. I wrote a few blog posts about the topic, where I reference this project. Have a look here:

It is an app where you can collect code snippets.

SwiftData problems and limitations

I wrote this project with Xcode 14 beta 2. There are still a lot of bugs with SwiftData. You can have a look at the list of reported issues in the latest Xcode release documentation: https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes and the iOS 17 beta release notes: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-17-release-notes

Data model

I used 3 model types: Folder, Snippet and Tag. There is a one-to-many relationship between Folder and Snippet and a many-to-many relationship between Snippet and Tag.

The Snippet type is the most interesting one, where I used different property types like Booleans, Integers, custom types, and image data.

SwiftData and Xcode Previews

I had quite a lot of problems with the previews. In the demo, I used a few different ways to pass SwiftData data to the preview. All previews are working. Note that this is very likely to improve in the upcoming betas.

Filtering and Sorting with SwiftData

SwiftData does not allow dynamically changing sorting and filtering for @Query like CoreData with @FetchResult. But you can set these parameters in the initializers. Have a look at the tag list, where I implemented searching and sorting.

Releases

No releases published

Packages

No packages published

Languages