             functions += "        return view\n"
             functions += "    }\n\n"
         }
+        functions += "}\n"
+        print(functions)
+    }
+    
+    private func printUIViewControllerExtensionFunctions() {
+        var functions = "extension UIViewController {\n\n"
+        for clazz in viewsList {
+            functions += "    func \(classNameToFunctionName(clazz))(views: (\(clazz)) -> ()) {\n"
+//            functions += "        let view = \(clazz)()\n"
+//            functions += "        self.view = view\n"
+//            functions += "        views(view)\n"
+            functions += "        self.view.\(classNameToFunctionName(clazz))(views)\n"
+            functions += "    }\n\n"
+        }
+        functions += "}\n"
         print(functions)
     }
 

        return name.substringToIndex(ind).lowercaseString + name.substringFromIndex(ind)
    }
    
    private func printExtensionFunctions() {
        var functions = ""
        for clazz in viewsList {
            functions += "    func \(classNameToFunctionName(clazz))(views: (\(clazz)) -> ()) -> " +
                "\(clazz) {\n"

        getSubclasses("UIView")
        
        printBegin()
        printUIViewExtensionFunctions()
        printUIViewControllerExtensionFunctions()
        printEnd()
    }
    
    private func printBegin() {
        var header = "// Generated code by Mango\n\n"
        header += "import UIKit\n\n"
        print(header)
    }
    
    private func printEnd() {
        var end = ""
        end += "extension UIStackView {\n"
        end += "    override internal func addChild(view: UIView) {\n"
        end += "        addArrangedSubview(view)\n"
        end += "    }\n"
        end += "}\n"
        print(end)
