Last active
February 27, 2017 00:48
-
-
Save rchatham/45cb632b628097406007a83f05cf4abd to your computer and use it in GitHub Desktop.
CoordinatorType Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] = [] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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