[swift-users] extension on UISlider breaks interface builder??

David Baraff davidbaraff at gmail.com
Fri Jul 14 22:51:18 CDT 2017


TL;DR
Add an extension to UISlider and interface builder in xcode will no longer believe it has *any* actions.
Is this a known issue?


1. I added a UISlider to a storyboard in xcode.  I right clicked on it, and saw the usual set of things, particularly, actions (sent events):



Next, I wrote this:

public protocol ModelDataValuedUIControl: class {
    var xxcontrolValue:Any {
        get set
    }
}

extension UISlider : ModelDataValuedUIControl {
    public var xxcontrolValue:Any {
        get {
            return self.value
        }
        
        set(newValue) {
            self.value = newValue as! Float
        }
    }
}


Lo and behold, after compiling, interface builder *hates* sliders, because now the rightclick menu looks like this:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170714/19deaf97/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-1.tiff
Type: image/tiff
Size: 109686 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170714/19deaf97/attachment.tiff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-2.tiff
Type: image/tiff
Size: 36398 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170714/19deaf97/attachment-0001.tiff>


More information about the swift-users mailing list