Instance Property インスタンスプロパティ

wrappedValue

The underlying value referenced by the state variable. 状態変数によって参照される基礎をなす値。

Declaration 宣言

var wrappedValue: Value { get nonmutating set }

Discussion 議論

This property provides primary access to the value’s data. However, you don’t access wrappedValue directly. このプロパティは、値のもつデータに対する主要なアクセスを提供します。しかしながら、あなたはwrappedValueに直接にアクセスしません。 Instead, you refer to the property variable created with the State attribute. In the following example, the button’s label depends on the value of isPlaying and its action toggles the value of isPlaying. Both of these accesses implicitly rely on the state property’s wrapped value.


struct PlayButton: View {
    @State private var isPlaying: Bool = false


    var body: some View {
        Button(isPlaying ? "Pause" : "Play") {
            isPlaying.toggle()
        }
    }
}

See Also 参照

Getting the Value 値を取得する