Skip to content

Instantly share code, notes, and snippets.

@scott-lydon
Created September 23, 2022 04:40
Show Gist options
  • Save scott-lydon/ae122a6ae6d25b114a48161e72f64367 to your computer and use it in GitHub Desktop.
Save scott-lydon/ae122a6ae6d25b114a48161e72f64367 to your computer and use it in GitHub Desktop.
extension UINavigationController {
// - MARK: Extracted reusable methods so that implementation changes reflect wherever used.
func viewController() {
navigationController.pushViewController(ViewController.instantiate(), animated: false)
}
func buySubscription() {
navigationController.pushViewController(BuyViewController.instantiate(), animated: true)
}
func createAccount() {
navigationController.pushViewController(CreateAccountViewController.instantiate(), animated: true)
}
}
// ----
// call site:
class ViewController: UIViewController {
@IBAction func buyTapped(_ sender: Any) {
navigationController?.buySubscription()
}
@IBAction func createAccount(_ sender: Any) {
navigationController?.createAccount()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment