 	}
 
 
-
-
-
 	/// Default identifier is the class name of the Coordinator subclass
-	public static var identifier: Identifier {
+	public static var identifier: String {
 		return String(describing: self)
 	}
 
-	open var identifier: Identifier {
+	open var identifier: String {
 		return type(of: self).identifier
 	}
+
 
 	/// Parent Coordinator
 	open var parentCoordinator: Coordinator<Any>?
+
+
 	///	A dictionary of child Coordinators, where key is Coordinator's identifier property
-	open var childCoordinators: [Identifier: Any] = [:]
+	open var childCoordinators: [String: Coordinator<Any>] = [:]
 
 
 


import UIKit

//	Must do 2-step dance due to the way Swift works with generic protocols
//	`associatedtype RootController` is needed to allow any kind of UIVC subclass to
//	become Coordinator's root VC
public protocol CoordinatorType: class {
	associatedtype RootController
	associatedtype Identifier

	/// You need to supply at least one UIViewController (or any of its subclasses) that will be loaded as root.
	///	Usually one of container controllers (UINavigationController, UITabBarController etc)
	///
	/// - parameter rootViewController: UIViewController at the top of the hierarchy.
	///
	/// - returns: Coordinator instance, prepared to start
	init(rootViewController: RootController?)

	/// The root view controller for a coordinator. 
	///	Each coordinator creates its VC hierarchy internally, so this is read-only property (post init)
	var rootViewController: RootController { get }

	///	Unique identifier for the Coordinator
	static var identifier: Identifier { get }
}


/**
Coordinators are a design pattern that encourages decoupling view controllers
such that they know as little as possible about how they are presented.

	- Parameter coordinator: The coordinator implementation to start.
	- Parameter completion: An optional `Callback` passed to the coordinator's `stop()` method.
	*/
	public func stopChild<U>(with identifier: String, type: U.Type, completion: @escaping Callback = {_ in}) {
		guard let c = childCoordinators[identifier] as? Coordinator<U> else { return }
		stopChild(coordinator: c, completion: completion)
	}
}

//	Inject parentCoordinator property into all UIViewControllers
extension UIViewController {
	private struct AssociatedKeys {
		static var ParentCoordinator = "ParentCoordinator"
	}
	///	*Must* be set for View Controller acting as Coordinator.rootViewController
	open var parentCoordinator: Coordinator<Any>? {
		get {
			//	DANGER: this returns Any! so if you call this and
			//	object is not really there, your app will crash
			return objc_getAssociatedObject(self, &AssociatedKeys.ParentCoordinator) as? Coordinator<Any>
		}
		set {
			objc_setAssociatedObject(self, &AssociatedKeys.ParentCoordinator, newValue, .OBJC_ASSOCIATION_RETAIN)
		}
	}
}

