Skip to content

Instantly share code, notes, and snippets.

@sagaya
Created January 21, 2019 17:04
Show Gist options
  • Save sagaya/9a90adc015a7de29e7a968c82523e74e to your computer and use it in GitHub Desktop.
Save sagaya/9a90adc015a7de29e7a968c82523e74e to your computer and use it in GitHub Desktop.
generic_controller
class BaseController<ViewType: UIView>: UIViewController, Controller {
var viewType: ViewType{
if let view = self.view as? ViewType {
return view
} else {
let view = ViewType()
self.view = view
return view
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.view = ViewType()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment