Structure

SceneStorage

A property wrapper type that reads and writes to persisted, per-scene storage. あるプロパティラッパー型、それは永続化された、シーンごとのストレージを読み書きします。

Declaration 宣言

@frozen @propertyWrapper struct SceneStorage<Value>

Overview 概要

You use SceneStorage when you need automatic state restoration of the value. SceneStorage works very similar to State, except its initial value is restored by the system if it was previously saved, and the value is· shared with other SceneStorage variables in the same scene.

The system manages the saving and restoring of SceneStorage on your behalf. The underlying data that backs SceneStorage is not available to you, so you must access it via the SceneStorage property wrapper. The system makes no guarantees as to when and how often the data will be persisted.

Each Scene has its own notion of SceneStorage, so data is not shared between scenes.

Ensure that the data you use with SceneStorage is lightweight. Data of a large size, such as model data, should not be stored in SceneStorage, as poor performance may result.

If the Scene is explicitly destroyed (e.g. the switcher snapshot is destroyed on iPadOS or the window is closed on macOS), the data is also destroyed. Do not use SceneStorage with sensitive data.

Topics 話題

Storing a Value

Storing an Optional Value

Getting the Value 値を取得する

Default Implementations 省略時実装

Relationships 関係

Conforms To 次に準拠

See Also 参照

App State