This code is legal in Swift:
class Snapper : NSObject {
var anim : UIDynamicAnimator
init(referenceView:UIView) {
self.anim = UIDynamicAnimator(referenceView:referenceView)
// super.init()
}
}
Observe that in my initializer I didn't call super.init()
; I commented out that line. But the Swift compiler doesn't complain. Why? I thought there was a rule that your designated initializer must call a designated initializer of its superclass. And I have a superclass, namely NSObject.
Is this a bug? Or is having NSObject as your superclass a special case? If so, why? I realize that NSObject has no instance variables that need initialization, but how do we know that its init
doesn't do other things that need doing? Shouldn't Swift be giving a compile error here?