As the @AppStorage
and @SceneStorage
property wrappers are only available in Views, this means I cannot specify them in my helper functions.
For instance a helper function convertFromKelvin(degreesK: Double) -> Double
may want to look up whether to return degrees Fahrenheit or Celsius, as defined in a variable attached to a View such as @AppStorage("tempScale") var tempScale = "C"
.
It seems logical to go the "old way" for this and reference NSUserDefaults.standard.string(forKey: "tempScale")
but is that "right" and how do I reference a @SceneStorage
variable? Is it sensible to pass the value on invocation of the function in the View? Or to pass a reference to the Scene, and if so, how would I do that?
It seems counterintuitive to have to pass anything around like that when the values are stored globally, or semi-globally in the Scene context.
Note that the use case I have requires the helper function to be available to multiple unrelated Views.