I am trying to subclass a UIView in Swift.
Howver the app crashes (EXC_BAD_ACCESS) when the initializer is called
Here is the class
class CustomActionSheet: UIView {
private var cancelButtonTitle: String!;
private var destructiveButtonTitle: String!;
private var otherButtonTitles: [String]!;
convenience init() {
self.init();//EXC_BAD_ACCESS
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder);
}
convenience init(cancelButtonTitle: String!, destructiveButtonTitle: String!, otherButtonTitles: [String]!) {
self.init();
self.cancelButtonTitle = cancelButtonTitle;
self.destructiveButtonTitle = destructiveButtonTitle;
self.otherButtonTitles = otherButtonTitles;
prepareUI();
}
func prepareUI() {
//BLABLABLABLABLA
}
}
Here is how I call it
var actionSheet: CustomActionSheet = CustomActionSheet(cancelButtonTitle: "Cancel", destructiveButtonTitle: "OK", otherButtonTitles: nil);
Tried to replace self.init() with super.init() but it won't compile.
Error Message:
Must call a designated initializer of the superclass 'UIView'
Convenience initializer for 'CustomActionSheet' must delegate (with 'self.init') rather than chaining to a superclass initializer (with 'super.init')