That’s expected, because the IBOutlet(s) are not assigned by the time the initializer is called.
Instead of calling commonInit()
in init(coder:)
, do that in an override of awakeFromNib
as follows:
// ...
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func awakeFromNib() {
super.awakeFromNib()
commonInit()
}
// ...