SwiftUI: SceneStorage Property Wrapper

A SwiftUI @SceneStorage property wrapper allows you to read and write persistent, scene specific scene data that is only available within views.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 08/13/2024 at 14:30
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 @SceneStorage property wrapper allows you to read and write persistent, scene specific scene data that is only available within views.

SubscribeDownload Open Source SwiftUI Starter ProjectDownload Open Source VisionOS Starter Project

SceneStorage is scene-scoped property wrapper that reads and writes data completely managed by SwiftUI. It is only accessible within views, making it a great candidate for holding lightweight information about the currently state of your app.

An example of this would be what movie or series you were browsing on Netflix so that it takes you directly to that view on launch.

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 SceneStorage in a SwiftUI view.</p>

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

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

Apple: SceneStorageSwiftUI: 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