[swift-evolution] Getting rid of willSet/didSet

Jack Lawrence jackl at apple.com
Tue Dec 15 01:49:25 CST 2015

I’m not sure I understand your example. `super` is a reference to the superclass implementation of `foo`, but `UIView` doesn’t declare a property called `foo`. 


> On Dec 14, 2015, at 11:23 PM, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
>> 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.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list