defaultAppStorage

The default store used by AppStorage contained within the view.

View ModifieriOS 14.0+macOS 11.0+tvOS 14.0+watchOS 7.0+defaultAppStorage(_:) in SwiftUI

Declaration

React
compose().defaultAppStorage(store: string)
Swift
nonisolated func defaultAppStorage(_ store: UserDefaults) -> some View

Parameters

  • store*string

    The user defaults to use as the default store for AppStorage.

Discussion

If unspecified, the default store for a view hierarchy is UserDefaults.standard, but can be set a to a custom one. For example, sharing defaults between an app and an extension can override the default store to one created with UserDefaults.init(suiteName:_).

See also

More in State and environment.