initialization - Why doesn't Swift force my designated initializer to call super? -
this code legal in swift:
class snapper : nsobject { var anim : uidynamicanimator init(referenceview:uiview) { self.anim = uidynamicanimator(referenceview:referenceview) // super.init() } }
observe in initializer didn't call super.init()
; commented out line. swift compiler doesn't complain. why? thought there rule designated initializer must call designated initializer of superclass. , have superclass, namely nsobject.
is bug? or having nsobject superclass special case? if so, why? realize nsobject has no instance variables need initialization, how know init
doesn't other things need doing? shouldn't swift giving compile error here?
it's not answer of why adding symbolic breakpoint on [nsobject init]
shows gets called if super.init()
commented out.
it seems special case replacing nsobject
other class makes compiler warn again missing super call. guess the compiler handles special case given it's our base class 1 known designated initializer.
Comments
Post a Comment