Type Safely

Type Safely

A SwiftUI Property Wrapper For The Keychain That Works Like AppStorage

Daily Coding Tip 032

Type Safely's avatar
Type Safely
Jan 19, 2021
∙ Paid
Image by Jon Pauling from Pixabay

When you want a property to be saved and loaded from the persistent storage called UserDefaults, you can declare it like this:

@AppStorage(“MyKey”) var savedValue

When the app launches, the key is used to retrieve the value. If there is a value, savedValue will have that value. When you change savedValue, UserDefaults is u…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture