Otherwise you will have to use UserDefaults directly, you can always use onChange and State to manage it. See this example of how to use onChange. You may need to create a custom init for your view so as to populate the State the value from UserDefaults.
Though you could write your own property wrapper, this article by John Sundell explains in detail how to do it.
Looking at the documentation for @AppStorage the only values that you can currently store using this property wrapper are
And their optional counterparts. You can also store values that conform to RawRepresentable, like enums that conform to Int or String.
If you want to store a dictionary using this method then you would have to convert it to data and store it that way.
Then we can save to it using
And if we want to retrieve it we can do the following:
Otherwise you will have to use UserDefaults directly, you can always use onChange and State to manage it. See this example of how to use onChange. You may need to create a custom init for your view so as to populate the State the value from UserDefaults.
Though you could write your own property wrapper, this article by John Sundell explains in detail how to do it.
https://stackoverflow.com/questions/62602279/using-appstorage-for-string-map/62602643#62602643