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: