Skip to content

Instantly share code, notes, and snippets.

@rchatham
Last active February 27, 2017 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchatham/45cb632b628097406007a83f05cf4abd to your computer and use it in GitHub Desktop.
Save rchatham/45cb632b628097406007a83f05cf4abd to your computer and use it in GitHub Desktop.
CoordinatorType Example
import UIKit
extension AppDelegate: CoordinatorType {
weak internal var delegate: CoordinatorTypeDelegate? { return nil }
internal var childCoordinators: [CoordinatorType] {
get {
return AppDelegate.Static.childCoordinators
}
set {
AppDelegate.Static.childCoordinators = newValue
}
}
internal func viewController() -> UIViewController {
let main = MainTabCoordinator()
main.delegate = self
childCoordinators.append(main)
return main.viewController()
}
private struct Static {
static var childCoordinators: [CoordinatorType] = []
}
}
import UIKit
@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.main.bounds)
window!.rootViewController = viewController()
window!.makeKeyAndVisible()
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment