How to pass UIViewController to another class in Swift?
<p>How to pass UIViewController to another class in Swift?
I have <code>SomeViewController</code> class:</p>

<pre><code>class RidingViewController: UIViewController {
    fileprivate let header = RidingViewHeader(controller: self)

    override func viewDidLoad() {
        super.viewDidLoad()
        header.setNavigationBar()
    }
    ...
}
</code></pre>

<p>And I want to separate some code and to set up its header in the another class. I've created this class</p>

<pre><code>class RidingViewHeader {

    var controller: UIViewController
    let navigationBar= UINavigationBar()
    let navigationItem = UINavigationItem()

    init(controller: UIViewController) {
        self.controller = controller
    }
    ...
}
</code></pre>

<p>In this case I get an error:
<code>Cannot convert value of type '(NSObject) -&gt; () -&gt; UIViewController' to expected argument type 'UIViewController'</code></p>

<p>What is the better way of doing it?</p>