title: Swift generic type property and method
body: <p>How do I store generic type in property and then use that type property to pass in method?</p>
  
  <p>I have factory whose method receives view controllers type but returns instance of that view controller (container takes care of that).</p>
  
  <pre><code>public protocol ViewControllerFactoryProtocol {
      func getViewController&lt;T: UIViewController&gt;(type: T.Type) -&gt; UIViewController
  }
  
  public class ViewControllerFactory: ViewControllerFactoryProtocol {
  
  private let container: Container
  
  public init(container: Container) {
      self.container = container
  }
  
  public func getViewController&lt;T: UIViewController&gt;(type: T.Type) -&gt; UIViewController {
      return self.container.resolve(type)!
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And I have property like this</p>
  
  <pre><code>var destinationViewController: UIViewController.Type { get }
  </code></pre>
  
  <p>Now I would like to do something like:</p>
  
  <pre><code>factory.getViewController(self.destinationViewController)
  </code></pre>
  
  <p>where I declare <code>destinationViewController</code> as <code>LoginViewController.self</code></p>
  
  <p>But its not working like that. Weird thing is that it is working if I do it directly:</p>
  
  <pre><code>factory.getViewController(LoginViewController.self)
  </code></pre>
  
  <p>Any help?? Thanks</p>