mvc的自定义初始化方法

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")
}

你可能感兴趣的:(mvc的自定义初始化方法)