SwiftUI: AppStorage Property Wrapper

A SwiftUI @AppStorage property wrapper allows you to read and write UserDefault values and updates relevant UI when the properties change.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 08/13/2024 at 13:53
Last Updated on 08/16/2024 at 13:51
<p>Two flowers that represents SwiftUI and XCode side by side with the text “Property Wrappers” beneath it.</p>

A SwiftUI @AppStorage property wrapper allows you to read and write UserDefault values and updates relevant UI when the properties change.

SubscribeDownload Open Source SwiftUI Starter ProjectDownload Open Source VisionOS Starter Project

AppStorage is app-scoped, global storage which is persisted using UserDefaults (i.e. small amounts of data, such as settings, that are held on device and do not reset when the app is closed or reopened). 

An example use of an AppStorage property wrapper can be found below and was found in Apple's WWDC20 Data Essentials in SwiftUI.

Apple: Data Essentials in SwiftUI (WWDC20)
<p>An example use of AppStorage in a SwiftUI view.</p>

Please note that in AppStorage it is important that each property has a unique key (i.e. updateArtwork and syncProgress) as they are independent pieces of data.

To learn more about the AppStorage property wrapper consult the link below.

Apple: AppStorageSwiftUI: What are property wrappers and which should I use?

Looking to learn more about SwiftUI, Swift, Design and Technology?

Search our blog to learn more about Swift, SwiftUI, design and technology.

Search our Blog

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe