ios - Call initializer from a Super Super Class in Swift? -
i have subclass of uitableviewcontroller
:
class classa : uitableviewcontroller { // mark: init convenience init() { self.init(style: .grouped) } convenience init(form: formdescriptor) { self.init() self.form = form } override init(style: uitableviewstyle) { super.init(style: style) } override init(nibname nibnameornil: string!, bundle nibbundleornil: nsbundle!) { super.init(nibname: nibnameornil, bundle: nibbundleornil) baseinit() } required init(coder adecoder: nscoder) { super.init(coder: adecoder) baseinit() } }
i made subclass of classa
:
class classb : classa { override init(style: uitableviewstyle) { super.init(style: style) } convenience init() { self.init(style: .grouped) self.form = getform() } required init(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } }
i tried init classb
initializer uitableviewcontroller
uses uitableviewstyle
. when running code get:
fatal error: use of unimplemented initializer
init(nibname:bundle:)
how can init classb
style
property uitableviewcontroller
?
put code in classb
:
override init(nibname nibnameornil: string!, bundle nibbundleornil: nsbundle!) { super.init(nibname: nibnameornil, bundle: nibbundleornil) }
then able init classb
follows:
let b = classb(style: uitableviewstyle.grouped)
Comments
Post a Comment