That's a cool hack! For a lighter way to distinguish overridable methods that 
one shouldn't ordinarily call, did anyone consider approximating "protected" 
(or as called in Objective-C speak, "private extension") methods with public 
class methods?

    public class UIView {
        public class func _layoutSubviews(_ view: UIView)
    }

This way, they become overridable, won't show up in the editor auto completion 
list for a given instance, and can be called… but definitely make you think 
twice before you do!

— Pyry

> Callionica (Swift) via swift-evolution <swift-evolution@swift.org> kirjoitti 
> 30.5.2016 kello 7.49:
> 
> I've written up how to provide protected access control for Swift code today 
> here:
> 
> http://www.callionica.com/developer/#swift-protected
> 
> No compiler changes necessary for this technique and it distinguishes between 
> methods that can only be overridden and methods that can be both called and 
> overridden.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to