Swift: how to work around issue where weak variable of type 'protocol' is illegal
<p>After reading some posts here regarding this issue, I discovered that my protocol should inherit from 'class' in order for 'weak' to work on my delegate variable.</p>

<p>'weak' may only be applied to class or class-bound protocol types.</p>

<p>If my protocol does not inherit from 'class', does swift 'infer' that it should be weak? </p>

<p>Is this the de facto way for casting a variable of type 'protocol' to weak ?</p>

<p>What happens in terms of memory management </p>

<pre><code>protocol FacebookLoginViewControllerDelegate: class {
    func facebookLoginViewControllerDidLogin(controller: FacebookLoginViewController)
}

class FacebookLoginViewController: UIViewController {

    weak var delegate: FacebookLoginViewControllerDelegate?

}
</code></pre>