Skip to content

Instantly share code, notes, and snippets.

@rlnucci
Last active May 29, 2020 00:46
Show Gist options
  • Select an option

  • Save rlnucci/b433889be7fde79a06ddd43af6af87d4 to your computer and use it in GitHub Desktop.

Select an option

Save rlnucci/b433889be7fde79a06ddd43af6af87d4 to your computer and use it in GitHub Desktop.
protocol NextCustomViewProtocol where Self: UIView {}
final class DefaultNextCustomView: UIView, NextCustomViewProtocol {
override init(frame: CGRect = .zero) {
super.init(frame: frame)
// setup here
}
required init?(coder: NSCoder) {
fatalError()
}
// setup methods goes here...
}
final class NextViewController: UIViewController {
private let nextCustomView: NextCustomViewProtocol
private let data: String
init(data: String, nextCustomView: NextCustomViewProtocol = DefaultNextCustomView()) {
self.nextCustomView = nextCustomView
self.data = data
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError()
}
override func loadView() {
view = nextCustomView
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment