<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AppStorage/init(wrappedValue:_:store:)-26q9z",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10AppStorageV12wrappedValue_5storeACyxGx_SSSo14NSUserDefaultsCSgtcSYRzSi03RawF0Rtzlufc"
  },
  "title" : "init(wrappedValue:_:store:)"
}
-->

# init(wrappedValue:_:store:)

Creates a property that can read and write to an integer user default,
transforming that to `RawRepresentable` data type.

```
init(wrappedValue: Value, _ key: String, store: UserDefaults? = nil) where Value : RawRepresentable, Value.RawValue == Int
```

## Parameters

`wrappedValue`

The default value if an integer value
is not specified for the given key.

`key`

The key to read and write the value to in the user defaults
store.

`store`

The user defaults store to read and write to. A value
of `nil` will use the user default store from the environment.

## Discussion

A common usage is with enumerations:

```
enum MyEnum: Int {
    case a
    case b
    case c
}
struct MyView: View {
    @AppStorage("MyEnumValue") private var value = MyEnum.a
    var body: some View { ... }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)