         }
     }
 
-    override open func popViewController(animated: Bool) -> UIViewController {
+    override  func popViewController(animated: Bool) -> UIViewController {
         return SafeUnwrapViewController(controller: super.popViewController(animated: animated)!)
     }
     
-    override open func popToRootViewController(animated: Bool) -> [UIViewController]? {
+    override  func popToRootViewController(animated: Bool) -> [UIViewController]? {
         return super.popToRootViewController(animated: animated)!.map{ (viewController) -> UIViewController in
           SafeUnwrapViewController(controller: viewController)
         }
     }
 
-    override open func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController] {
+    override  func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? {
         var controllerToPop: UIViewController? = nil
         for item in super.viewControllers {
             if SafeUnwrapViewController(controller: item) == viewController {

        })
    }

    var rt_topViewController: UIViewController {
        return SafeUnwrapViewController(controller: super.topViewController!)
    }

    func onBack(_ sender: Any) {
        _ = self.popViewController(animated: true)
    }
    
    func _commonInit() {
    }
    
    // The output below is limited by 4 KB.
    // Upgrade your plan to remove this limitation.
    
    // MARK: - Overrides
    
    override open func awakeFromNib() {
        self.viewControllers = super.viewControllers
    }
    
    required public init() {
       super.init(nibName: nil, bundle: nil)
    }
    
    required public init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        
        self._commonInit()
    }
    
    override init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?) {
        super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
        
        self._commonInit()
        
    }

    override init(rootViewController: UIViewController) {
        super.init(rootViewController: SafeWrapViewController(controller: rootViewController, navigationBarClass: rootViewController.navigationBarClass))
        self._commonInit()
    }
    
    convenience init(rootViewControllerNoWrapping rootViewController: UIViewController) {
        self.init()
        
        super.pushViewController(rootViewController, animated: false)
        self._commonInit()
        
    }
    
    override open func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
        super.delegate = self
        super.setNavigationBarHidden(true, animated: false)
    }

    override open func setNavigationBarHidden(_ hidden:  Bool, animated:  Bool) {
        // Override to protect
    }

    override open func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if self.viewControllers.count > 0 {
            let currentLast = SafeUnwrapViewController(controller: self.viewControllers.last!)
            super.pushViewController(SafeWrapViewController(controller: viewController,

//

import Foundation
import UIKit

func SafeWrapViewController(controller: UIViewController,
                            navigationBarClass: AnyClass? = nil,
                            withPlaceholder: Bool = false,
                            backItem: UIBarButtonItem? = nil,
                            backTitle: String? = nil) -> UIViewController {
    if !(controller is WrapperViewController) {
        return WrapperViewController(controller: controller, navigationBarClass: navigationBarClass, withPlaceholderController: withPlaceholder, back: backItem, backTitle: backTitle)
    }
    return controller
}

func SafeUnwrapViewController(controller: UIViewController) -> UIViewController {
    
    if (controller is WrapperViewController) {
        return (controller as! WrapperViewController).contentViewController
    }
    return controller
}


 class RootNavigationController: UINavigationController, UINavigationControllerDelegate {
    fileprivate weak var rt_delegate: UINavigationControllerDelegate?
    fileprivate var animationBlock: ((Bool) -> Void)?

    // TOOD: 加 is
   @IBInspectable var useSystemBackBarButtonItem = false
   @IBInspectable var transferNavigationBarAttributes = false
    
    var rt_topViewController: UIViewController {
        return SafeUnwrapViewController(controller: super.topViewController!)
    }
    
    var rt_visibleViewController: UIViewController {
        return SafeUnwrapViewController(controller: super.visibleViewController!)
    }
