SceneStorage vs AppStorage - SwiftUI

Jan 03, 2021 1 min read
SceneStorage vs AppStorage - SwiftUI

SceneStorage

In simple words, it saves the state of your app so when the app is killed or switched it comes back to where you were before, same goes for the data, it stays the same.

If you want to save unique data for each of your screens, you should use SwiftUI’s @SceneStorage property wrapper. This works a bit like @AppStorage in that you provide it with a name to save things plus a default value, but rather than working with UserDefaults it instead gets used for state restoration – and it even works great with the kinds of complex multi-scene set ups we see so often in iPadOS.

Watch a demo:

AppStorage

This is like a storage on your app, you can save data and reuse it later once the app comes back, however it doesn't save the state of the app like SceneStorage.

Watch a demo:

Great! Next, complete checkout for full access to ArturoFM.
Welcome back! You've successfully signed in.
You've successfully subscribed to ArturoFM.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.