iOS 17.2 Update, Confusing SwiftData Update !

Hi,

Before the iOS 17.2 update the saving behavior of SwiftData was very straightforward, by default it saves to persistence storage and can be configured to save in memory only. Now it saves to memory by default and to make it save to persistence storage we need to use modelContext.Save(). But if we don't quit the App the changes will be saved after a while to persistence storage even without running modelContext.Save() ! How confusing can that be for both developer and the user ! Am I missing something here ?

-- Kind Regards

It still saves to disk by default, what has changed is when it saves. It used to be rather quickly but now as you mentioned it saves with a much larger delay or when the app quits or goes into the background.

and disabling autosave is still an option ? how it works now if disabled ?

Setting autosaveEnabled to false disables auto-save. You can definitely choose to do so and take care the model context saving by your own.

Having said that, please feel free to file a feedback report if you see auto-save doesn't work as you would expect – If you do so, please share your report ID here for folks to track.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

iOS 17.2 Update, Confusing SwiftData Update !
 
 
Q