ios - Custom class initialisation in swift -


i'm trying implement custom class extending uicontrol in swift , can't quite work out initialisation.

class uirangeslider: uicontrol {     var minimumvalue: float32     var maximumvalue: float32      required init(coder adecoder: nscoder) {         super.init(coder: adecoder)     }      init(frame: cgrect, minimumvalue: float32, maximumvalue: float32) {         self.minimumvalue = minimumvalue         self.maximumvalue = maximumvalue         super.init(frame: frame)     } } 

when try create instance of class with:

var sliderframe = cgrect(x: 20, y: 200, width: 200, height: 5) var slider = uirangeslider(frame: sliderframe, minimumvalue: 1, maximumvalue: 10) 

i error:

property 'self.minimumvalue' not initialised @ super.init call 

what correct way write custom initialiser?

swift requires new members of class have kind of default value before can call designated init.

required init(coder adecoder: nscoder) {     self.minimumvalue = 0.0 // default value     self.maximumvalue = 0.0 // default value      super.init(coder: adecoder) } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -