关于swift构造方法
switf 中如果遇到这样的错,,,大概错误就是,"必须要调用父类的构造方法",,可是呢,,调用了super.init() 不就是调用了构造方法了吗?
结果上去一查,,结果一名外国大神 "Therefore what you'll do is call init(nibName:bundle:)
, and since this view controller has no nib file, just pass nil
for the nib name. This in fact is what super.init()
was doing in the earlier version of Swift - it was calling init(nibName:bundle:)
with nil
values for you. So nothing is really lost or changed."
意思就是说,,必须要调用最底层的构造方法,,
结果如下