A few weeks ago Graham was asking how to make instances of his NSView subclass 
redraw themselves automatically when their custom properties were changed. 
During the discussion he said something like “wouldn’t it be great if you could 
declare a property as “(redraw)” and then it would automatically redraw the 
view when it changed.” Which got shot down (rightly IMHO) for hardcoding 
AppKit/UIKit-specific behavior into the language.

But now there’s a new Swift language proposal to add a general-purpose 
extensible “behaviors” mechanism to properties. It would let Graham do pretty 
much exactly what he described — someone would just have to write a snippet of 
Swift code to implement the “redraw” behavior, which could be done either in 
the app or in the UI framework itself.

Take a look, it’s a pretty cool proposal. Joe Groff gives examples of how it 
can be used to implement existing Swift (and Obj-C) property behaviors like 
atomic, lazy, and copying.

        
https://github.com/apple/swift-evolution/blob/master/proposals/0030-property-behavior-decls.md

(Discussion should happen on the swift-evolution mailing list, not here, unless 
it’s something specific to a “redraw” behavior. 
https://lists.swift.org/mailman/listinfo/swift-evolution 
<https://lists.swift.org/mailman/listinfo/swift-evolution> )

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to