Prompt Setup

Set Up @AppStorage and Defaults

Configure UserDefaults-backed preferences with @AppStorage and a settings model.

swiftswiftuimacosios
Insert label AppStorage
Prompt

Set up preferences storage using @AppStorage. Create a centralized enum or struct for UserDefaults keys to avoid string duplication. Add typed @AppStorage properties in views that need them. For complex types, implement RawRepresentable conformance. Include sensible defaults and handle the case where stored data is from an older schema.

Add this to your Facet Inserts in Crystl for one-click access.

Get Crystl