Contents

autosaveEnabled

A Boolean value that indicates whether the context should automatically save any pending changes when certain events occur.

Declaration

var autosaveEnabled: Bool { get set }

Mentioned in

Discussion

When true, the context calls save() after you make changes to any inserted or registered models. The context also calls save() at various times during the lifecycle of windows, scenes, views, and sheets.

The default value is false. SwiftData automatically sets this property to true for the model container’s mainContext.

See Also

Persisting unsaved changes