Is it possible to allow didSet to be called during initialization in Swift?

Question Apple’s docs specify that: willSet and didSet observers are not called when a property is first initialized. They are only called when the property’s value is set outside of an initialization context. Is it possible to force these to be called during initialization? Why? Let’s say I have this class class SomeClass { var … Read more

What is the purpose of willSet and didSet in Swift?

Swift has a property declaration syntax very similar to C#’s: var foo: Int { get { return getFoo() } set { setFoo(newValue) } } However, it also has willSet and didSet actions. These are called before and after the setter is called, respectively. What is their purpose, considering that you could just have the same … Read more