3 posts tagged ‘SwiftData’
Data Tracking and Notifications in Core Data and SwiftData
Fatbobman (Mastodon): [prepareForDeletion is called] when the managed object is about to be deleted, typically used for cleaning up resources or manually managing relationships. Note that this method is triggered before validateForDelete. If the deletion operation fails due to validation failure, changes made in this method may be rolled back.[…]However, because these operations are extensions […]
SwiftData Fetching Pending Changes
Keith Harrison: If you don’t want the pending changes included in the fetch results you should be able to override the default by setting includePendingChanges to false in the fetch descriptor[…] Unfortunately, I don’t seem to be able to get that to work using iOS 17.2 (FB13509125). The pending change is always returned in the […]
Unit Testing a SwiftUI Query
Helge Heß: I’ve been wondering whether I could unit test a SwiftData Query, i.e. the SwiftUI property wrapper coming w/ SwiftData (in beta6 it is actually a macro). Aka whether I could unit test a SwiftUI view. This requires setting up an execution environment for the view, but surprisingly that actually works 🙂 Here’s the […]