I have the following class representing a button in my iOS 8 custom keyboard:
internal class KeyButton: UIButton {
required init(char: Character) {
super.init()
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Since KeyButton is not initialised via storyboard
the constructor (coder: NSCoder)
would never be called.
The problem is that I am required to implement (coder: NSCoder)
constructor, when I run the app I receive the exception plugin interrupted
when instantiating KeyButton
.
Why am I required to implement (coder: NSCoder)
constructor although I instantiate everything programatically
It has nothing to do with the coder.
UIButton
'sinit()
callsinit(frame: CGRect)
, which you haven't implemented. Add the following, and you should be good to go...