mvc的自定义初始化方法
2018-05-08 本文已影响17人
码客波锣
1.view的自定义初始化方法。(当有子控件需要依赖参数布局时)
convenience init(delegate:ListSectionFooterProtocol) {
self.init()
self.delegate = delegate
self.layoutControl()
}
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }
2.controller的自定义初始化方法
init(status:OrderStatus, orderId: String) {
viewModel = DetailViewModel.init(orderStatus: status, orderId: orderId)
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}