Initializer

init(wrappedValue:_:)

Creates a property that can save and restore a string, transforming it to a RawRepresentable data type.

Declaration 宣言

init(wrappedValue: Value, _ key: String) where Value : RawRepresentable, Value.RawValue == String

Parameters パラメータ

wrappedValue

The default value if a String value is not available for the given key.

key

a key used to save and restore the value.

Discussion 議論

A common usage is with enumerations: 一般的な使用法は、列挙でとなります:

enum MyEnum: String { case a case b case c } struct MyView: View { @SceneStorage(“MyEnumValue”) private var value = MyEnum.a var body: some View { … } }

See Also 参照

Storing a Value