What is equivalent of id<type> in Swift?
<p>I have two delegates like this:</p>

<pre><code>protocol MyFirstDelegate {
  func change(value: int) 
}

protocol MySecondDelegate {
  weak var delegate: MyFirstDelegate?
}
</code></pre>

<p>Those protocols are implemented in two customized UIViewControllers:</p>

<pre><code>class MyFirstViewController: UIViewController, MyFirstDelegate {
  ...
}

class MySecondViewController: UIViewController, MySecondDelegate {
  ...
}
</code></pre>

<p>The first UI view controller will push second UI view controller by using a segue.</p>

<p>In my first UI view controller class I have the following codes to prepare segue:</p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
  if let vc = (segue.destinationViewController) as? MySecondViewController {
    vc.delegate = self
  }
}
</code></pre>

<p>The above codes compile without any problem. However, I think that the first UI controller has knowledge about the next view controller class. I prefer to pass delegate like this:</p>

<pre><code>override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
  if var vc = (segue.destinationViewController) as? MySecondDelegate {
    vc.delegate = self
  }
}
</code></pre>

<p>I got compiling error: </p>

<pre><code>Cannot assign to property: "vc" is immutable.
</code></pre>

<p>It seems that as to a concrete UI view controller is OK, but not to a protocol. Any explanation and solution to this?</p>

<p>By the way, in Objective-C, this can be done like this:</p>

<pre><code>id&lt;NSObject, MySecondDelegate&gt; vc = segue.destinationViewController;
vc.delegate = self;
</code></pre>

<p>I could not find a way in swift to define a variable like </p>

<pre><code>let vc: AnyObject&lt;type&gt;? // like id&lt;type&gt;
</code></pre>

<p><strong>UPDATES</strong></p>

<p>As @David_Berry solution, it works if I mark protocol as class. The above codes are actually simplified ones. I am in the middle of converting my ObjC codes to Swift. Therefore, I have to mark protocols as objc:</p>

<pre><code>@objc protocol MyFirstDelegate : class {
  func change(value: int) 
}

@objc protocol MySecondDelegate {
  weak var delegate: MyFirstDelegate?
}
</code></pre>

<p>with @objc, I still get the same compiling error.</p>