UserDefaults & AppStorage
Last updated
What is UserDefaults & AppStorage?
UserDefaults and AppStorage are mechanisms in Swift and SwiftUI for storing small amounts of data persistently on a user's device. UserDefaults is a traditional way to store simple data types like strings, numbers, and booleans, using key-value pairs. AppStorage, built on top of UserDefaults, provides a more SwiftUI-friendly way to bind data directly to UI elements, automatically saving and loading values as the user interacts with the app.
Free resources to learn UserDefaults & AppStorage
- Official docsUserDefaults
- ArticleUser Defaults reading and writing in Swift
- VideoStoring user settings with UserDefaults
- Official docsAppStorage
- ArticleWhat is the @AppStorage property wrapper?
- Article@AppStorage explained and replicated for a better alternative
- VideoHow to use @AppStorage in SwiftUI | Bootcamp #52
More in stage 34: Data persistance
UserDefaults & AppStorage: common questions
Can I learn UserDefaults & AppStorage in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain UserDefaults & AppStorage in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this UserDefaults & AppStorage tutorial for beginners?
It is lesson 113 of 156 in the free Swift & Swift UI roadmap, in stage 34, Data persistance. If you are new to Swift & Swift UI, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.