I am looking to create a custom subclass of UIAlertController
.
If I understand correctly, I need to call the super.init(title...
somewhere during the subclasses initialization.
But I keep running into problems with designated initializers. I have read the documentation and cannot figure out how to get it to work. Here's my code (note the comments in the code):
class AccountInfoActionSheet: UIAlertController {
required init?(coder aDecoder: NSCoder) { //xcode says I need this
super.init(coder: aDecoder) //it also says I need to call a designated initializers so here it is
super.init(title: "Info", message: "Heres the Info", preferredStyle: .actionSheet) //but now I can't call this initializer
fatalError("init(coder:) has not been implemented")
}
}
EDIT: Since UIAlertController
cannot be subclassed I simply created a function that returns the correctly configured UIAlertController
inside the ViewController where it is needed.