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.
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.
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.
Looking to learn more about SwiftUI, Swift, Design and Technology?
Search our blog to learn more about Swift, SwiftUI, design and technology.