[swift-evolution] Getting rid of willSet/didSet

Tino Heth 2th at gmx.de
Tue Dec 15 01:23:13 CST 2015


> It *is* odd, and I do the described didSet trick *all* the time.
> 
> Stuff like:
The alternative wouldn’t be that complicated:

public class MyView: UIView {
	public var foo: Int {
		set(value) {
			super.foo = value
			setNeedsDisplay()
		}
	}
}

It’s just one line more, but three(!) keywords less that could be removed from the language; and I bet in the wild there are many thousand errors in subclasses of UIViewController that happen because the author didn’t remember wether he has to call super in viewDid…, loadView etc.


More information about the swift-evolution mailing list