title: In Swift, how can I declare a variable of a specific type that conforms to one or more protocols?
body: <p>In Swift I can explicitly set the type of a variable by declaring it as follows:</p>
  <pre><code>var object: TYPE_NAME
  </code></pre>
  <p>If we want to take it a step further and declare a variable that conforms to multiple protocols we can use the <code>protocol</code> declarative:</p>
  <pre><code>var object: protocol&lt;ProtocolOne,ProtocolTwo&gt;//etc
  </code></pre>
  <p>What if I would like to declare an object that conforms to one or more protocols and is also of a specific base class type? The Objective-C equivalent would look like this:</p>
  <pre><code>NSSomething&lt;ABCProtocolOne,ABCProtocolTwo&gt; * object = ...;
  </code></pre>
  <p>In Swift I would expect it to look like this:</p>
  <pre><code>var object: TYPE_NAME,ProtocolOne//etc
  </code></pre>
  <p>This gives us the flexibility of being able to deal with the implementation of the base type as well as the added interface defined in the protocol.</p>
  <p>Is there another more obvious way that I might be missing?</p>
  <h2>Example</h2>
  <p>As an example, say I have a <code>UITableViewCell</code> factory that is responsible for returning cells conforming to a protocol. We can easily setup a generic function that returns cells conforming to a protocol:</p>
  <pre><code>class CellFactory {
      class func createCellForItem&lt;T: UITableViewCell where T:MyProtocol &gt;(item: SpecialItem,tableView: UITableView) -&gt; T {
          //etc
      }
  }
  </code></pre>
  <p>later on I want to dequeue these cells whilst leveraging both the type and the protocol</p>
  <pre><code>var cell: MyProtocol = CellFactory.createCellForItem(somethingAtIndexPath) as UITableViewCell
  </code></pre>
  <p>This returns an error because a table view cell does not conform to the protocol...</p>
  <p>I would like to be able to specify that cell is a <code>UITableViewCell</code> and conforms to the <code>MyProtocol</code> in the variable declaration?</p>
  <h2>Justification</h2>
  <p>If you are familiar with the <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" rel="noreferrer">Factory Pattern</a> this would make sense in the context of being able to return objects of a particular class that implement a certain interface.</p>
  <p>Just like in my example, sometimes we like to define interfaces that make sense when applied to a particular object. My example of the table view cell is one such justification.</p>
  <p>Whilst the supplied type does not exactly conform to the mentioned interface, the object the factory returns does and so I would like the flexibility in interacting with both the base class type and the declared protocol interface</p>