ananthbh / SurveyList

0 stars 0 forks source link

Convenience init #13

Open teamdisc opened 6 years ago

teamdisc commented 6 years ago

Most of the view controllers have their own viewModel as SomeViewModel! because that convenience init is used. I think we can remove ! and change convenience init to just init if we change self.init() to super.init(nibName:bundle:) instead. For example, we could do something like this:

private let viewModel: SomeViewModel

init(viewModel: SomeViewModel) {
    self.viewModel = viewModel
    super.init() // or super.init(nibName: nil, bundle: nil)
}

Something like this would help us prevent the viewModel property getting mutated unintentionally and it'll look safer in my opinion 😁

ananthbh commented 6 years ago

Thanks for the feedback. This seems to be a pretty efficient solution