Próbuję dokonać podklasy UIView w Swift.Przesłanianie init() w aplikacji awarii CustomUIView (EXC_BAD ACCESS)
Howver awarie app (EXC_BAD_ACCESS), gdy inicjator nazywa
Oto klasa
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
}
}
Oto jak ja to nazywam
var actionSheet: CustomActionSheet = CustomActionSheet(cancelButtonTitle: "Cancel", destructiveButtonTitle: "OK", otherButtonTitles: nil);
Tried aby zamienić self.init() na super.init(), ale to nie będzie co mpile.
Komunikat o błędzie:
Musi zadzwonić do wyznaczonego inicjator superklasy 'UIView'
Convenience inicjator dla 'CustomActionSheet' musi przekazać (z 'self.init') zamiast do łączenia inicjator superklasy (z "super.init")
Czy chcesz umieścić super.init() w miejscu z błędem? – spektr
super.init() nie będzie nawet kompilować @choward. Zaktualizowałem moje pytanie. – JayVDiyk