Skip to content

Instantly share code, notes, and snippets.

@scott-lydon
Created September 23, 2022 16:04
Show Gist options
  • Save scott-lydon/620fa0001b503b39967cf683b3cda1f5 to your computer and use it in GitHub Desktop.
Save scott-lydon/620fa0001b503b39967cf683b3cda1f5 to your computer and use it in GitHub Desktop.
import UIKit
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)
}
}
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