Because property observers observe and respond to changes, why they cannot observe and respond to change in a property wrapper?
There happens to be an error
If that being so, the willSet and didSet property observers would change to func.
Someone tell me if we can do that or not?
Code Block import Foundation @propertyWrapper struct Property { private var number: Int = 0 private var maximum: Int = 0 var wrappedValue: Int { get { return number } set { number = min(newValue, maximum) } } init() { maximum = 12 number = 0 } init(wrappedValue: Int) { maximum = 12 number = min(wrappedValue, maximum) } init(wrappedValue: Int, maximum: Int) { self.maximum = maximum number = min(wrappedValue, maximum) } willSet() {} didSet() {} } struct SmallRectangle { @Property(wrappedValue: 12, maximum: 25) var _height: Int @Property(wrappedValue: 12, maximum: 25) var _width: Int } var smallRectangle = SmallRectangle() smallRectangle._height = 18 print(smallRectangle._height)
There happens to be an error
at line 29 and 30."Expected 'func' keyword in instance method declaration"
If that being so, the willSet and didSet property observers would change to func.
Someone tell me if we can do that or not?