You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposals/0258-property-wrappers.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -144,8 +144,8 @@ translates to:
144
144
```swift
145
145
var $foo: Lazy<Int>= Lazy<Int>(initialValue: 1738)
146
146
var foo: Int {
147
-
get { return $foo.value }
148
-
set { $foo.value= newValue }
147
+
get { return $foo.wrappedValue }
148
+
set { $foo.wrappedValue= newValue }
149
149
}
150
150
```
151
151
@@ -643,8 +643,8 @@ Composition is implemented by nesting later wrapper types inside earlier wrapper
643
643
```swift
644
644
var $path: DelayedMutable<Copying<UIBezierPath>>= .init()
645
645
var path: UIBezierPath {
646
-
get { return $path.value.value }
647
-
set { $path.value.value= newValue }
646
+
get { return $path.wrappedValue.wrappedValue }
647
+
set { $path.wrappedValue.wrappedValue= newValue }
648
648
}
649
649
```
650
650
@@ -695,7 +695,7 @@ in one of three ways:
695
695
696
696
// ... implemented as
697
697
var $foo: Lazy =Lazy(initialValue: 17)
698
-
var foo: Int { /* access via $foo.value as described above */ }
698
+
var foo: Int { /* access via $foo.wrappedValue as described above */ }
699
699
```
700
700
When there are multiple, composed property wrappers, all of them must provide an `init(initialValue:)`, and the resulting initialization will wrap each level of call:
701
701
@@ -704,7 +704,7 @@ in one of three ways:
704
704
705
705
// ... implemented as
706
706
var $path: Lazy<Copying<UIBezierPath>>= .init(initialValue: .init(initialValue: UIBezierPath()))
707
-
var path: UIBezierPath { /* access via $path.value.value as described above */ }
707
+
var path: UIBezierPath { /* access via $path.wrappedValue.wrappedValue as described above */ }
708
708
```
709
709
710
710
2. Via a value of the property wrapper type, by placing the initializer
@@ -718,7 +718,7 @@ in one of three ways:
718
718
719
719
// ... implemented as
720
720
var $someInt:UnsafeMutablePointer<Int>=UnsafeMutablePointer(mutating: addressOfInt)
721
-
var someInt: Int { /* access via $someInt.value*/ }
721
+
var someInt: Int { /* access via $someInt.wrappedValue*/ }
722
722
```
723
723
724
724
When there are multiple, composed property wrappers, only the first (outermost) wrapper may have initializer arguments.
@@ -730,7 +730,7 @@ in one of three ways:
730
730
731
731
// ... implemented as
732
732
var $x: DelayedMutable<Int>= DelayedMutable<Int>()
733
-
var x: Int { /* access via $x.value*/ }
733
+
var x: Int { /* access via $x.wrappedValue*/ }
734
734
```
735
735
736
736
When there are multiple, composed property wrappers, only the first (outermost) wrapper needs to have an `init()`.
@@ -892,7 +892,7 @@ apply to properties that have wrappers. Let's expand the example of
892
892
// ...
893
893
x2 =17// okay, treated as $x2 = .init(initialValue: 17)
894
894
// ...
895
-
x2 =42// okay, treated as x2 = 42 (calls the Lazy.value setter)
895
+
x2 =42// okay, treated as x2 = 42 (calls the Lazy.wrappedValue setter)
896
896
```
897
897
898
898
### Memberwise initializers
@@ -1102,8 +1102,8 @@ struct AB<Value> {
1102
1102
privatevar storage: A<B<Value>>
1103
1103
1104
1104
var wrappedValue: Value {
1105
-
get { storage.value.value }
1106
-
set { storage.value.value= newValue }
1105
+
get { storage.wrappedValue.wrappedValue }
1106
+
set { storage.wrappedValue.wrappedValue= newValue }
0 commit comments