Type Safely

Type Safely

Share this post

Type Safely
Type Safely
A SwiftUI Property Wrapper For The Keychain That Works Like AppStorage

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

Share this post

Type Safely
Type Safely
A SwiftUI Property Wrapper For The Keychain That Works Like AppStorage
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share