title: Reference to class that conforms to a protocol
body: <p>Let's say I have a protocol that looks like this:</p>
  
  <pre><code>protocol Foo {
      var bar: Bool { get set }
  }
  </code></pre>
  
  <p>Now I have my view controller that conforms to the Foo protocol;</p>
  
  <pre><code>class FooViewController: UIViewController, Foo {
      ...
  }
  </code></pre>
  
  <p>In another class I want to do something like this:</p>
  
  <pre><code>class FooClass {
  
      var viewController: UIViewController? // this should conform to Foo protocol
  
      func setViewController(viewController: UIViewController) {
          if let fooVC = viewController as? Foo {
              // viewController implements Foo protocol
              self.viewController = fooVC
          } else {
              print("ViewController does not conform to Foo protocol")
          }
      }
  }
  </code></pre>
  
  <p>In Objective-C I would have a reference that looks like: <code>UIViewController&lt;Foo&gt; *vc</code> saying that vc is an object of class UIViewController conforming to Foo protocol. Is there a Swift equivalent?</p>
  
  <p><strong>EDIT:</strong> I guess it's <a href="https://stackoverflow.com/questions/25172430/how-to-declare-a-property-of-a-particular-class-which-is-also-protocol-conforman?rq=1">not possible</a> :(</p>